Example #1
0
File: util.c Project: HarryR/sanos
void cstr_cat(CString *cstr, const char *str) {
  int c;
  for (;;) {
    c = *str;
    if (c == '\0') break;
    cstr_ccat(cstr, c);
    str++;
  }
}
Example #2
0
File: util.c Project: HarryR/sanos
void add_char(CString *cstr, int c)
{
  if (c == '\'' || c == '\"' || c == '\\') {
    // TODO: could be more precise if char or string
    cstr_ccat(cstr, '\\');
  }
  if (c >= 32 && c <= 126) {
    cstr_ccat(cstr, c);
  } else {
    cstr_ccat(cstr, '\\');
    if (c == '\n') {
      cstr_ccat(cstr, 'n');
    } else {
      cstr_ccat(cstr, '0' + ((c >> 6) & 7));
      cstr_ccat(cstr, '0' + ((c >> 3) & 7));
      cstr_ccat(cstr, '0' + (c & 7));
    }
  }
}
Example #3
0
static void tcc_split_path(TCCState *s, void ***p_ary, int *p_nb_ary, const char *in)
{
	const char *p;
	do {
		int c;
		CString str;

		cstr_new (&str);
		for (p = in; c = *p, c != '\0' && c != PATHSEP; ++p) {
			if (c == '{' && p[1] && p[2] == '}') {
				c = p[1], p += 2;
				if (c == 'B') {
					cstr_cat (&str, s->tcc_lib_path);
				}
			} else {
				cstr_ccat (&str, c);
			}
		}
		cstr_ccat (&str, '\0');
		dynarray_add (p_ary, p_nb_ary, str.data);
		in = p + 1;
	} while (*p);
}
Example #4
0
void cstr_cstring(SCTX_ CString *cstr)
{
	if (!cstr->size || ((unsigned char *)cstr->data)[cstr->size-1] != 0)
		cstr_ccat(sctx_ cstr, 0);
}