Ejemplo n.º 1
0
void litehtml::el_before_after_base::add_text( const tstring& txt )
{
	tstring word;
	tstring esc;
	for(tstring::size_type i = 0; i < txt.length(); i++)
	{
		if( (txt.at(i) == _t(' ')) || (txt.at(i) == _t('\t')) || (txt.at(i) == _t('\\') && !esc.empty()) )
		{
			if(esc.empty())
			{
				if(!word.empty())
				{
					element::ptr el = std::make_shared<el_text>(word.c_str(), get_document());
					appendChild(el);
					word.clear();
				}

				element::ptr el = std::make_shared<el_space>(txt.substr(i, 1).c_str(), get_document());
				appendChild(el);
			} else
			{
				word += convert_escape(esc.c_str() + 1);
				esc.clear();
				if(txt.at(i) == _t('\\'))
				{
					esc += txt.at(i);
				}
			}
		} else
		{
			if(!esc.empty() || txt.at(i) == _t('\\'))
			{
				esc += txt.at(i);
			} else
			{
				word += txt.at(i);
			}
		}
	}

	if(!esc.empty())
	{
		word += convert_escape(esc.c_str() + 1);
	}
	if(!word.empty())
	{
		element::ptr el = std::make_shared<el_text>(word.c_str(), get_document());
		appendChild(el);
		word.clear();
	}
}
Ejemplo n.º 2
0
static void
parse_one_string (struct obstack *output, char *data, int len,
		  const char *dest_charset, struct type *type)
{
  char *limit;

  limit = data + len;

  while (data < limit)
    {
      char *p = data;

      /* Look for next escape, or the end of the input.  */
      while (p < limit && *p != '\\')
	++p;
      /* If we saw a run of characters, convert them all.  */
      if (p > data)
	convert_between_encodings (host_charset (), dest_charset,
				   (gdb_byte *) data, p - data, 1,
				   output, translit_none);
      /* If we saw an escape, convert it.  */
      if (p < limit)
	p = convert_escape (type, dest_charset, p, limit, output);
      data = p;
    }
}
Ejemplo n.º 3
0
/* Check the "format" string. */
static int format_check_string(const char *format)
{
	const char *in_str = format;

	while (*in_str) {
		/* Just skip normal characters. */
		if (*in_str != '%')
		  {
		    if (*in_str == '\\')
		      convert_escape(*++in_str);
		    ++in_str;
		    continue;
		  }
		/* Ensure that the replacement is there. */
		if (*++in_str == '\0') {
			error("missing replacement");
			return -1;
		}
		/* Process the replacement as required. */
		switch (*in_str++) {

		case '%':
		case 'a':
		case 'd':
		case 'n':
		case 'l':
		case 'p':
			break;

		case '{':{
				char *end = strchr(in_str, '}');

				/* Make sure the %{...} is formatted correctly. */
				if (!end) {
					error("unterminated %%{...} construct");
					return -1;
				}
				if (end - in_str > MAX_TAG_LEN - 1) {
					error("%%{...} construct is too large");
					return -1;
				}
				/* Advance past the end of the replacement. */
				in_str = end + 1;
				break;
			}

		default:
			error("%c: unknown replacement", in_str[-1]);
			return -1;
		}		/* switch */
	}			/* while */
	return 0;
}
Ejemplo n.º 4
0
/* Format one line of the "format" string based on the module contents. */
static void format_query_line(struct obj_file *f, const char *format,
			      char *key, char *value, const char *desc)
{
	int c;
	const char *in_str = format;

	while (*in_str) {
		/* Just copy normal characters into the output. */
		if (*in_str != '%')
		  {
		    if (*in_str == '\\')
		      c = convert_escape(*++in_str);
		    else
		      c = *in_str;

		    ++in_str;

		    putchar (c);
		    if (c == '\n')
			    break;
		    continue;
		  }
		++in_str;
		/* Process the replacement as required. */
		switch (*in_str++) {

		case '%':
			putchar ('%');
			break;

		case 'a':
			append_modinfo_tag(f, "author", "<none>", 1);
			break;

		case 'd':
			append_modinfo_tag(f, "description", "<none>", 1);
			break;

		case 'n':
			append_modinfo_tag(f, "filename", "<none>", 0);
			break;

		case 'l':
			append_modinfo_tag(f, "license", "<none>", 1);
			break;

		case 'p':
			show_parameter(f, key, value, desc);
			break;

		case '{':{
				char tag[MAX_TAG_LEN];
				char *end = strchr(in_str, '}');
				int multi_line;

				/* Copy out the tag name. */
				memset(tag, 0, sizeof(tag));
				strncpy(tag, in_str, end - in_str);
				tag[end - in_str] = '\0';
				multi_line = strcmp(tag, "author") == 0 ||
					     strcmp(tag, "description") == 0 ||
					     strcmp(tag, "license") == 0;

				if (strcmp (tag, "parm") != 0)
				        /* Append the tag's value if it exists. */
					append_modinfo_tag(f, tag, "<none>", multi_line);
				else
					show_parameter(f, key, value, desc);

				/* Advance past the end of the replacement. */
				in_str = end + 1;
				break;
			}
		}		/* switch */
	}			/* while */
}