static void do_texio_ini_print(lua_State * L, const char *extra) { const char *s; int i = 1; int l = term_and_log; int n = lua_gettop(L); if (n > 1) { if (get_selector_value(L, i, &l)) i++; } for (; i <= n; i++) { if (lua_isstring(L, i)) { s = lua_tostring(L, i); if (l == term_and_log || l == term_only) fprintf(stdout, "%s%s", extra, s); if (l == log_only || l == term_and_log) { if (loggable_info == NULL) { loggable_info = strdup(s); } else { char *v = concat3(loggable_info, extra, s); free(loggable_info); loggable_info = v; } } } } }
/* Start the recorder */ static void recorder_start(void) { /* Alas, while we'd like to use mkstemp it is not portable, and doing the autoconfiscation (and providing fallbacks) is more than we want to cope with. So we have to be content with using a default name. Throw in the pid so at least parallel builds might work (Debian bug 575731). */ string cwd; char pid_str[MAX_INT_LENGTH]; /* Windows (MSVC) seems to have no pid_t, so instead of storing the value returned by getpid() we immediately consume it. */ sprintf (pid_str, "%ld", (long) getpid()); recorder_name = concat3(kpse_program_name, pid_str, ".fls"); /* If an output directory was specified, use it instead of cwd. */ if (output_directory) { string temp = concat3(output_directory, DIR_SEP_STRING, recorder_name); free(recorder_name); recorder_name = temp; } recorder_file = xfopen(recorder_name, FOPEN_W_MODE); cwd = xgetcwd(); fprintf(recorder_file, "PWD %s\n", cwd); free(cwd); }
static string kpse_expand_kpse_dot P1C(string, path) { string ret, elt; string kpse_dot = getenv("KPSE_DOT"); #ifdef MSDOS boolean malloced_kpse_dot = false; #endif if (kpse_dot == NULL) return path; ret = (string)xmalloc(1); *ret = 0; #ifdef MSDOS /* Some setups of ported Bash force $KPSE_DOT to have the //d/foo/bar form (when `pwd' is used), which is not understood by libc and the OS. Convert them back to the usual d:/foo/bar form. */ if (kpse_dot[0] == '/' && kpse_dot[1] == '/' && kpse_dot[2] >= 'A' && kpse_dot[2] <= 'z' && kpse_dot[3] == '/') { kpse_dot++; kpse_dot = xstrdup (kpse_dot); kpse_dot[0] = kpse_dot[1]; /* drive letter */ kpse_dot[1] = ':'; malloced_kpse_dot = true; } #endif for (elt = kpse_path_element (path); elt; elt = kpse_path_element (NULL)) { string save_ret = ret; boolean ret_copied = true; /* We assume that the !! magic is only used on absolute components. Single "." gets special treatment, as does "./" or its equivalent. */ if (kpse_absolute_p (elt, false) || (elt[0] == '!' && elt[1] == '!')) { ret = concat3(ret, elt, ENV_SEP_STRING); } else if (elt[0] == '.' && elt[1] == 0) { ret = concat3 (ret, kpse_dot, ENV_SEP_STRING); #ifndef VMS } else if (elt[0] == '.' && IS_DIR_SEP(elt[1])) { ret = concatn (ret, kpse_dot, elt + 1, ENV_SEP_STRING, NULL); } else if (*elt) { ret = concatn (ret, kpse_dot, DIR_SEP_STRING, elt, ENV_SEP_STRING, NULL); #endif } else { /* omit empty path elements from TEXMFCNF. See http://bugs.debian.org/358330. */ ret_copied = false; } if (ret_copied) free (save_ret); } #ifdef MSDOS if (malloced_kpse_dot) free (kpse_dot); #endif ret[strlen (ret) - 1] = 0; return ret; }
static const char* is_if (const char* line) { uintL n = strlen(line); uintL i = 0; /* Skip whitespace. */ for (; i < n && is_whitespace(line[i]); i++) {} /* Parse a '#'. */ if (i < n && line[i] == '#') i++; else return NULL; /* Skip whitespace. */ for (; i < n && is_whitespace(line[i]); i++) {} /* Check for "if". */ if (i+2 < n && line[i+0] == 'i' && line[i+1] == 'f' && is_whitespace(line[i+2])) { i += 3; for (; i < n && is_whitespace(line[i]); i++) {} for (; n > i && is_whitespace(line[n-1]); n--) {} return substring(line,i,n); } /* Check for "ifdef". */ if (i+5 < n && line[i+0] == 'i' && line[i+1] == 'f' && line[i+2] == 'd' && line[i+3] == 'e' && line[i+4] == 'f' && is_whitespace(line[i+5])) { i += 6; for (; i < n && is_whitespace(line[i]); i++) {} for (; n > i && is_whitespace(line[n-1]); n--) {} { char* term = substring(line,i,n); const char* result = concat3("defined(",term,")"); xfree(term); return result; } } /* Check for "ifndef". */ if (i+6 < n && line[i+0] == 'i' && line[i+1] == 'f' && line[i+2] == 'n' && line[i+3] == 'd' && line[i+4] == 'e' && line[i+5] == 'f' && is_whitespace(line[i+6])) { i += 7; for (; i < n && is_whitespace(line[i]); i++) {} for (; n > i && is_whitespace(line[n-1]); n--) {} { char* term = substring(line,i,n); const char* result = concat3("!defined(",term,")"); xfree(term); return result; } } return NULL; }
static string kpse_brace_expand_element P1C(const_string, elt) { unsigned i; str_list_type expansions = brace_expand (&elt); string ret = (string)xmalloc (1); *ret = 0; for (i = 0; i != STR_LIST_LENGTH(expansions); i++) { /* Do $ and ~ expansion on each element. */ string x = kpse_expand (STR_LIST_ELT(expansions,i)); string save_ret = ret; if (!STREQ (x, STR_LIST_ELT(expansions,i))) { /* If we did any expansions, do brace expansion again. Since recursive variable definitions are not allowed, this recursion must terminate. (In practice, it's unlikely there will ever be more than one level of recursion.) */ string save_x = x; x = kpse_brace_expand_element (x); free (save_x); } ret = concat3 (ret, x, ENV_SEP_STRING); free (save_ret); free (x); } for (i = 0; i != STR_LIST_LENGTH(expansions); ++i) { free(STR_LIST_ELT(expansions,i)); } str_list_free(&expansions); ret[strlen (ret) - 1] = 0; /* waste the trailing null */ return ret; }
int main(){ //Testar exo 1 char s1[10] ="marianas"; char s2[4] ="ana"; char* o = strstr(s1, s2); printf("%s %s %s\n ", s1, s2, o); // //Testar exo2 int v[4] ={ 90, 4, 80, 2}; int in = maxInd(v, 4); printf("O indice do maior valor no vetor v é %d cujo elemento é %d\n", in, v[in]); //Testar exo 3 printf("Antes do concat\n"); LInt a = (LInt)malloc(sizeof(struct slist)); a->valor = 10; a->prox = (LInt)malloc(sizeof(struct slist)); a->prox->valor = 20; a->prox->prox = NULL; printL(a); LInt b = (LInt)malloc(sizeof(struct slist)); b->valor = 30; b->prox = (LInt)malloc(sizeof(struct slist)); b->prox->valor = 40; b->prox->prox= NULL; printL(b); concat3(&a, b); printf("Depois do concat\n"); //a = concat(a,b); printL(a); //Testar exo4 printf("Exo 4\n"); ABin ar = (ABin)malloc(sizeof(struct nodo)); ar->valor = 50; ar->esq = (ABin)malloc(sizeof(struct nodo)); ar->esq->valor = 30; ar->esq->esq = NULL; ar->esq->dir=NULL; ar->dir = (ABin)malloc(sizeof(struct nodo)); ar->dir->valor = 80; ar->dir->esq = NULL; ar->dir->dir = NULL; LInt lis = nivel(ar, 2); printL(lis); return 0; }
String c_AsyncFunctionWaitHandle::getName() { switch (getState()) { case STATE_BLOCKED: case STATE_SCHEDULED: case STATE_RUNNING: { String funcName; if (actRec()->func()->isClosureBody()) { // Can we do better than this? funcName = s__closure_; } else { funcName = actRec()->func()->name()->data(); } String clsName; if (actRec()->hasThis()) { clsName = actRec()->getThis()->getVMClass()->name()->data(); } else if (actRec()->hasClass()) { clsName = actRec()->getClass()->name()->data(); } else { return funcName; } return concat3(clsName, "::", funcName); } default: throw FatalErrorException( "Invariant violation: encountered unexpected state"); } }
// move void pallet_id(const PalletMovement *movement) { printf("pallet_id: Adding id [%s] to pallet with rfid [%s] and [%s]\n", movement->id, movement->pallet, movement->pallet2); char *time = get_time_string(); const char *keys[5] = { "reader", "palletId", "tag1", "tag2", "time" }; const char *values[5] = { movement->reader, movement->id, movement->pallet, movement->pallet2, time }; char *parameters = to_parameters(5, keys, values); char *URL = concat3(BASE_URL, SERVER_MOVE_START, parameters); movements_add(URL); free(time); free(parameters); free(URL); }
void place_id(const PalletMovement *movement) { printf("place_id: Adding tag to place [%s], with rfid tag [%s]\n", movement->id, movement->placement); char *time = get_time_string(); const char *keys[4] = { "reader", "place", "p", "time" }; printf("Values place_id: reader: [%s] id: [%s] tag: [%s] time: [%s]\n", movement->reader, movement->id, movement->placement, time); const char *values[4] = { movement->reader, movement->id, movement->placement, time }; printf("URL snart"); char *parameters = to_parameters(4, keys, values); char *URL = concat3(BASE_URL, SERVER_MOVE_START, parameters); printf("URL: %s", URL); movements_add(URL); free(time); free(parameters); free(URL); }
static void appdef(char ***lstp, const char *def) { appstrg(lstp, concat2("-D__", def)); appstrg(lstp, concat3("-D__", def, "__")); }
static void do_texio_ini_print (lua_State *L, char *extra) { char *s; int i,n,l; n = lua_gettop(L); i = 1; l = 3; if (n>1) { s=(char *)lua_tostring(L, 1); if (strcmp(s,"log") == 0) { i++; l = 1; } else if (strcmp(s,"term") == 0) { i++; l = 2; } else if (strcmp(s,"term and log") == 0) { i++; l = 3; } } for (;i<=n;i++) { if(lua_isstring(L, i)) { s = (char *)lua_tostring(L, i); if (l==2||l==3) fprintf(stdout,"%s%s", extra, s); if (l==1||l==3) { if (loggable_info==NULL) { loggable_info = strdup(s); } else { char *v = concat3 (loggable_info,extra,s); free(loggable_info); loggable_info = v; } } } } }
String c_Continuation::t_getorigfuncname() { INSTANCE_METHOD_INJECTION_BUILTIN(Continuation, Continuation::getorigfuncname); String called_class; if (hhvm) { if (actRec()->hasThis()) { called_class = actRec()->getThis()->getVMClass()->name()->data(); } else if (actRec()->hasClass()) { called_class = actRec()->getClass()->name()->data(); } } else { called_class = getCalledClass(); } if (called_class.size() == 0) { return m_origFuncName; } /* Replace the class name in m_origFuncName with the LSB class. This produces more useful traces. */ size_t method_pos = m_origFuncName.find("::"); if (method_pos != std::string::npos) { return concat3(called_class, "::", m_origFuncName.substr(method_pos+2)); } else { return m_origFuncName; } }
/* Expand all special constructs in a path, and include only the actually existing directories in the result. */ string kpse_path_expand P1C(const_string, path) { string ret; string xpath; string elt; unsigned len; /* Initialise ret to the empty string. */ ret = (string)xmalloc (1); *ret = 0; len = 0; /* Expand variables and braces first. */ xpath = kpse_brace_expand (path); /* Now expand each of the path elements, printing the results */ for (elt = kpse_path_element (xpath); elt; elt = kpse_path_element (NULL)) { str_llist_type *dirs; /* Skip and ignore magic leading chars. */ if (*elt == '!' && *(elt + 1) == '!') elt += 2; /* Search the disk for all dirs in the component specified. Be faster to check the database, but this is more reliable. */ dirs = kpse_element_dirs (elt); if (dirs && *dirs) { str_llist_elt_type *dir; for (dir = *dirs; dir; dir = STR_LLIST_NEXT (*dir)) { string thedir = STR_LLIST (*dir); unsigned dirlen = strlen (thedir); string save_ret = ret; /* We need to retain trailing slash if that's the root directory. * On unix, "/" is root dir, "" often taken to be current dir. * On windows, "C:/" is root dir of drive C, and "C:" is current * on drive C. There's no need to look at other cases, like UNC * names. */ if (dirlen == 1 || (dirlen == 3 && NAME_BEGINS_WITH_DEVICE (thedir) && IS_DIR_SEP (thedir[2]))) { ret = concat3 (ret, thedir, ENV_SEP_STRING); len += dirlen + 1; ret[len - 1] = ENV_SEP; } else { ret = concat (ret, thedir); len += dirlen; ret [len - 1] = ENV_SEP; } free (save_ret); } } } /* Get rid of trailing ':', if any. */ if (len != 0) ret[len - 1] = 0; return ret; }
static void do_else () { VectorString* v = StackVectorString_peek(ifdef_stack); uintL i = VectorString_length(v) - 1; const char* lastcondition = VectorString_element(v,i); lastcondition = concat3("!(",lastcondition,")"); VectorString_set_element(v,i,lastcondition); }
string kpathsea_var_value (kpathsea kpse, const_string var) { string vtry, ret; const_string value; assert (kpse->program_name); /* First look for VAR.progname. */ vtry = concat3 (var, ".", kpse->program_name); value = getenv (vtry); free (vtry); if (!value || !*value) { /* Now look for VAR_progname. */ vtry = concat3 (var, "_", kpse->program_name); value = getenv (vtry); free (vtry); } /* Just plain VAR. */ if (!value || !*value) value = getenv (var); /* Not in the environment; check a config file. */ if (!value || !*value) value = kpathsea_cnf_get (kpse, var); /* We have a value; do variable and tilde expansion. We want to use ~ in the cnf files, to adapt nicely to Windows and to avoid extra /'s (see tilde.c), but we also want kpsewhich -var-value=foo to not have any literal ~ characters, so our shell scripts don't have to worry about doing the ~ expansion. */ ret = value ? kpathsea_expand (kpse, value) : NULL; #ifdef KPSE_DEBUG if (KPATHSEA_DEBUG_P (KPSE_DEBUG_VARS)) DEBUGF2("variable: %s = %s\n", var, ret ? ret : "(nil)"); #endif return ret; }
/* SRC: classes/directoryiterator.php line 14 */ void c_DirectoryIterator::t___construct(Variant v_path) { INSTANCE_METHOD_INJECTION_BUILTIN(DirectoryIterator, DirectoryIterator::__construct); if (!(x_hphp_directoryiterator___construct(GET_THIS_TYPED(DirectoryIterator), toString(v_path)))) { { { p_UnexpectedValueException tmp0 = coo_UnexpectedValueException(); throw_exception(((c_UnexpectedValueException*)tmp0.get()->create(concat3(NAMSTR(s_sys_ss19fa93f0, "DirectoryIterator::__construct("), toString(v_path), NAMSTR(s_sys_ss4e2ff123, "): failed to open dir"))), tmp0)); } } } }
static Variant HHVM_FUNCTION(assert, const Variant& assertion, const Variant& message /* = null */) { if (!s_option_data->assertActive) return true; CallerFrame cf; Offset callerOffset; auto const fp = cf(&callerOffset); auto const passed = [&]() -> bool { if (assertion.isString()) { if (RuntimeOption::EvalAuthoritativeMode) { // We could support this with compile-time string literals, // but it's not yet implemented. throw_not_supported("assert()", "assert with strings argument in RepoAuthoritative mode"); } return eval_for_assert(fp, assertion.toString()).toBoolean(); } return assertion.toBoolean(); }(); if (passed) return true; if (!s_option_data->assertCallback.isNull()) { auto const unit = fp->m_func->unit(); PackedArrayInit ai(3); ai.append(String(const_cast<StringData*>(unit->filepath()))); ai.append(Variant(unit->getLineNumber(callerOffset))); ai.append(assertion.isString() ? assertion : empty_string_variant_ref); HHVM_FN(call_user_func)(s_option_data->assertCallback, ai.toArray()); } if (s_option_data->assertException) { if (message.isObject()) { Object exn = message.toObject(); if (exn.instanceof(SystemLib::s_AssertionErrorClass)) { throw_object(exn); } } SystemLib::throwExceptionObject(message.toString()); } if (s_option_data->assertWarning) { String name(message.isNull() ? "Assertion" : message.toString()); auto const str = !assertion.isString() ? " failed" : concat3(" \"", assertion.toString(), "\" failed"); raise_warning("assert(): %s%s", name.data(), str.data()); } if (s_option_data->assertBail) { throw ExitException(1); } return init_null(); }
string make_output_filename (string name, string default_suffix) { string new_s; string suffix = find_suffix (name); new_s = suffix == NULL ? concat3 (name, ".", default_suffix) : xstrdup (name); return new_s; }
void xputenv P2C(const_string, var_name, const_string, value) { static const_string *saved_env_items; static unsigned saved_len; string old_item = NULL; string new_item = concat3 (var_name, "=", value); #ifndef SMART_PUTENV /* Check if we have saved anything yet. */ if (!saved_env_items) { saved_env_items = XTALLOC1 (const_string); saved_env_items[0] = var_name; saved_len = 1; } else { /* Check if we've assigned VAR_NAME before. */ unsigned i; unsigned len = strlen (var_name); for (i = 0; i < saved_len && !old_item; i++) { if (STREQ (saved_env_items[i], var_name)) { old_item = getenv (var_name); assert (old_item); old_item -= (len + 1); /* Back up to the `NAME='. */ } } if (!old_item) { /* If we haven't seen VAR_NAME before, save it. Assume it is in safe storage. */ saved_len++; XRETALLOC (saved_env_items, saved_len, const_string); saved_env_items[saved_len - 1] = var_name; } } #endif /* not SMART_PUTENV */ /* As far as I can see there's no way to distinguish between the various errors; putenv doesn't have errno values. */ if (putenv (new_item) < 0) FATAL1 ("putenv (%s) failed", new_item); #ifndef SMART_PUTENV /* Can't free `new_item' because its contained value is now in `environ', but we can free `old_item', since it's been replaced. */ if (old_item) free (old_item); #endif /* not SMART_PUTENV */ }
boolean open_output (FILE **f_ptr, const_string fopen_mode) { string fname; boolean absolute = kpse_absolute_p(nameoffile+1, false); /* If we have an explicit output directory, use it. */ if (output_directory && !absolute) { fname = concat3(output_directory, DIR_SEP_STRING, nameoffile + 1); } else { fname = nameoffile + 1; } /* Is the filename openable as given? */ *f_ptr = fopen (fname, fopen_mode); if (!*f_ptr) { /* Can't open as given. Try the envvar. */ string texmfoutput = kpse_var_value("TEXMFOUTPUT"); if (texmfoutput && *texmfoutput && !absolute) { if (fname != nameoffile + 1) free(fname); fname = concat3(texmfoutput, DIR_SEP_STRING, nameoffile+1); *f_ptr = fopen(fname, fopen_mode); } } /* If this succeeded, change nameoffile accordingly. */ if (*f_ptr) { if (fname != nameoffile + 1) { free (nameoffile); namelength = strlen (fname); nameoffile = xmalloc (namelength + 2); strcpy (nameoffile + 1, fname); } recorder_record_output (fname); } if (fname != nameoffile +1) free(fname); return *f_ptr != NULL; }
/* SRC: classes/directoryiterator.php line 132 */ void c_RecursiveDirectoryIterator::t___construct(Variant v_path, Variant v_flags // = 16L /* RecursiveDirectoryIterator::CURRENT_AS_FILEINFO */ ) { INSTANCE_METHOD_INJECTION_BUILTIN(RecursiveDirectoryIterator, RecursiveDirectoryIterator::__construct); if (!(x_hphp_recursivedirectoryiterator___construct(GET_THIS_TYPED(RecursiveDirectoryIterator), toString(v_path), toInt64(v_flags)))) { { { p_UnexpectedValueException tmp0 = coo_UnexpectedValueException(); throw_exception(((c_UnexpectedValueException*)tmp0.get()->create(concat3(NAMSTR(s_sys_ss224978df, "RecursiveDirectoryIterator::__construct("), toString(v_path), NAMSTR(s_sys_ss4e2ff123, "): failed to open dir"))), tmp0)); } } } }
/* SRC: classes/exception.php line 123 */ String c_Exception::t_gettraceasstring() { INSTANCE_METHOD_INJECTION_BUILTIN(Exception, Exception::getTraceAsString); int64 v_i = 0; String v_s; Variant v_frame; v_i = 0LL; v_s = NAMSTR(s_sys_ss00000000, ""); { LOOP_COUNTER(1); Variant map2 = t_gettrace(); { StringBuffer tmp_sbuf_v_s(512); for (ArrayIter iter3 = map2.begin(s_class_name); !iter3.end(); iter3.next()) { LOOP_COUNTER_CHECK(1); iter3.second(v_frame); { if (!(x_is_array(v_frame))) { continue; } { tmp_sbuf_v_s.appendWithTaint("#", 1); tmp_sbuf_v_s.appendWithTaint(toString(v_i)); tmp_sbuf_v_s.appendWithTaint(" ", 1); tmp_sbuf_v_s.appendWithTaint(toString((isset(v_frame, NAMSTR(s_sys_ss8ce7db5b, "file"), true) ? ((Variant)(v_frame.rvalAt(NAMSTR(s_sys_ss8ce7db5b, "file"), AccessFlags::Error_Key))) : ((Variant)(NAMSTR(s_sys_ss00000000, "")))))); tmp_sbuf_v_s.appendWithTaint("(", 1); tmp_sbuf_v_s.appendWithTaint(toString((isset(v_frame, NAMSTR(s_sys_ssddf8728c, "line"), true) ? ((Variant)(v_frame.rvalAt(NAMSTR(s_sys_ssddf8728c, "line"), AccessFlags::Error_Key))) : ((Variant)(NAMSTR(s_sys_ss00000000, "")))))); tmp_sbuf_v_s.appendWithTaint("): ", 3); Variant tmp0; if (isset(v_frame, NAMSTR(s_sys_ssc82dbd12, "class"), true)) { const String &tmp1((toString(v_frame.rvalAt(NAMSTR(s_sys_ssc82dbd12, "class"), AccessFlags::Error_Key)))); const String &tmp2((toString(v_frame.rvalAt(NAMSTR(s_sys_ss724a760a, "type"), AccessFlags::Error_Key)))); tmp0 = (concat(tmp1, tmp2)); } else { tmp0 = (NAMSTR(s_sys_ss00000000, "")); } tmp_sbuf_v_s.appendWithTaint(toString(tmp0)); tmp_sbuf_v_s.appendWithTaint(toString(v_frame.rvalAt(NAMSTR(s_sys_ss52403931, "function"), AccessFlags::Error_Key))); tmp_sbuf_v_s.appendWithTaint("()\n", 3); ; } v_i++; } } concat_assign(v_s, tmp_sbuf_v_s.detachWithTaint()); } } concat_assign(v_s, concat3(NAMSTR(s_sys_ss8dc355aa, "#"), toString(v_i), NAMSTR(s_sys_ssfab32402, " {main}"))); return v_s; }
static void misstex (kpathsea kpse, kpse_file_format_type format, string *args) { string *s; /* If we weren't trying to make a font, do nothing. Maybe should allow people to specify what they want recorded? */ if (format != kpse_gf_format && format != kpse_pk_format && format != kpse_any_glyph_format && format != kpse_tfm_format && format != kpse_vf_format) return; /* If this is the first time, have to open the log file. But don't bother logging anything if they were discarding errors. */ if (!kpse->missfont && !kpse->make_tex_discard_errors) { const_string missfont_name = kpathsea_var_value (kpse, "MISSFONT_LOG"); if (!missfont_name || *missfont_name == '1') { missfont_name = "missfont.log"; /* take default name */ } else if (missfont_name && (*missfont_name == 0 || *missfont_name == '0')) { missfont_name = NULL; /* user requested no missfont.log */ } /* else use user's name */ kpse->missfont = missfont_name ? fopen (missfont_name, FOPEN_A_MODE) : NULL; if (!kpse->missfont && kpathsea_var_value (kpse, "TEXMFOUTPUT")) { missfont_name = concat3 (kpathsea_var_value (kpse, "TEXMFOUTPUT"), DIR_SEP_STRING, missfont_name); kpse->missfont = fopen (missfont_name, FOPEN_A_MODE); } if (kpse->missfont) fprintf (stderr, "kpathsea: Appending font creation commands to %s.\n", missfont_name); } /* Write the command if we have a log file. */ if (kpse->missfont) { fputs (args[0], kpse->missfont); for (s = &args[1]; *s != NULL; s++) { putc(' ', kpse->missfont); fputs (*s, kpse->missfont); } putc ('\n', kpse->missfont); } }
const_string kpathsea_cnf_get (kpathsea kpse, const_string name) { string ctry; const_string ret, *ret_list; /* When we expand the compile-time value for DEFAULT_TEXMFCNF, we end up needing the value for TETEXDIR and other variables, so kpse_var_expand ends up calling us again. No good. Except this code is not sufficient, somehow the ls-R path needs to be computed when initializing the cnf path. Better to ensure that the compile-time path does not contain variable references. */ if (kpse->doing_cnf_init) return NULL; if (kpse->cnf_hash.size == 0) { /* Read configuration files and initialize databases. */ kpse->doing_cnf_init = true; read_all_cnf (kpse); kpse->doing_cnf_init = false; /* Since `kpse_init_db' recursively calls us, we must call it from outside a `kpse_path_element' loop (namely, the one in `read_all_cnf' above): `kpse_path_element' is not reentrant. */ kpathsea_init_db (kpse); } /* First look up NAME.`kpse->program_name', then NAME. */ assert (kpse->program_name); ctry = concat3 (name, ".", kpse->program_name); ret_list = hash_lookup (kpse->cnf_hash, ctry); free (ctry); if (ret_list) { ret = *ret_list; free (ret_list); } else { ret_list = hash_lookup (kpse->cnf_hash, name); if (ret_list) { ret = *ret_list; free (ret_list); } else { ret = NULL; } } return ret; }
String c_AsyncFunctionWaitHandle::getName() { switch (getState()) { case STATE_BLOCKED: case STATE_READY: case STATE_RUNNING: { auto func = actRec()->func(); if (!actRec()->getThisOrClass() || func->cls()->attrs() & AttrNoOverride) { auto name = func->fullName(); if (func->isClosureBody()) { const char* p = strchr(name->data(), ':'); if (p) { return concat(String(name->data(), p + 1 - name->data(), CopyString), s__closure_); } else { return s__closure_; } } return String{const_cast<StringData*>(name)}; } String funcName; if (actRec()->func()->isClosureBody()) { // Can we do better than this? funcName = s__closure_; } else { funcName = const_cast<StringData*>(actRec()->func()->name()); } String clsName; if (actRec()->hasThis()) { clsName = const_cast<StringData*>(actRec()->getThis()-> getVMClass()->name()); } else if (actRec()->hasClass()) { clsName = const_cast<StringData*>(actRec()->getClass()->name()); } else { return funcName; } return concat3(clsName, "::", funcName); } default: raise_fatal_error( "Invariant violation: encountered unexpected state"); } }
string kpse_cnf_get P1C(const_string, name) { string ret, ctry; string *ret_list; static boolean doing_cnf_init = false; /* When we expand the compile-time value for DEFAULT_TEXMFCNF, we end up needing the value for TETEXDIR and other variables, so kpse_var_expand ends up calling us again. No good. */ if (doing_cnf_init) return NULL; if (cnf_hash.size == 0) { doing_cnf_init = true; read_all_cnf (); doing_cnf_init = false; /* Here's a pleasant kludge: Since `kpse_init_dbs' recursively calls us, we must call it from outside a `kpse_path_element' loop (namely, the one in `read_all_cnf' above): `kpse_path_element' is not reentrant. */ kpse_init_db (); } /* First look up NAME.`kpse_program_name', then NAME. */ assert (kpse_program_name); ctry = concat3 (name, ".", kpse_program_name); ret_list = hash_lookup (cnf_hash, ctry); free (ctry); if (ret_list) { ret = *ret_list; free (ret_list); } else { ret_list = hash_lookup (cnf_hash, name); if (ret_list) { ret = *ret_list; free (ret_list); } else { ret = NULL; } } return ret; }
search P3C(kpse_file_format_type, format, char *, file, char *, mode) { FILE *ret; string found_name; #ifdef SECURE /* This change suggested by [email protected] to disallow reading of arbitrary files. */ if (secure && kpse_absolute_p (file)) return NULL; #endif /* Most file looked for through here must exist -- the exception is VF's. Bitmap fonts go through pksearch. */ found_name = kpse_find_file (file, format, format != vfpath); if (found_name) { unsigned len = strlen (found_name); #ifndef AMIGA if ((format == figpath || format == headerpath) && ((len > 2 && FILESTRCASEEQ (found_name + len - 2, ".Z")) || (len > 3 && FILESTRCASEEQ (found_name + len - 3, ".gz")))) { /* FIXME : use zlib instead of gzip ! */ char *cmd = concat3 (GUNZIP, " -c ", found_name); ret = popen (cmd, "r"); to_close = USE_PCLOSE ; } else { #endif /* not AMIGA */ ret = fopen (found_name, mode); to_close = USE_FCLOSE ; #ifndef AMIGA } #endif /* not AMIGA */ if (!ret) FATAL_PERROR (found_name); /* Free result of previous search. */ if (realnameoffile) free (realnameoffile); /* Save in `name' and `realnameoffile' because other routines access those globals. Sigh. */ realnameoffile = found_name; strcpy(name, realnameoffile); } else ret = NULL; return ret; } /* end search */
static Variant HHVM_FUNCTION(assert, const Variant& assertion) { if (!s_option_data->assertActive) return true; JIT::CallerFrame cf; Offset callerOffset; auto const fp = cf(&callerOffset); auto const passed = [&]() -> bool { if (assertion.isString()) { if (RuntimeOption::EvalAuthoritativeMode) { // We could support this with compile-time string literals, // but it's not yet implemented. throw NotSupportedException(__func__, "assert with strings argument in RepoAuthoritative mode"); } return eval_for_assert(fp, assertion.toString()).toBoolean(); } return assertion.toBoolean(); }(); if (passed) return true; if (!s_option_data->assertCallback.isNull()) { auto const unit = fp->m_func->unit(); PackedArrayInit ai(3); ai.append(String(const_cast<StringData*>(unit->filepath()))); ai.append(Variant(unit->getLineNumber(callerOffset))); ai.append(assertion.isString() ? assertion.toString() : static_cast<String>(empty_string)); f_call_user_func(1, s_option_data->assertCallback, ai.toArray()); } if (s_option_data->assertWarning) { auto const str = !assertion.isString() ? String("Assertion failed") : concat3("Assertion \"", assertion.toString(), "\" failed"); raise_warning("%s", str.data()); } if (s_option_data->assertBail) { throw Assertion(); } return uninit_null(); }
Variant f_assert(CVarRef assertion) { if (!s_option_data->assertActive) return true; Transl::CallerFrame cf; Offset callerOffset; auto const fp = cf(&callerOffset); auto const passed = [&]() -> bool { if (assertion.isString()) { if (RuntimeOption::RepoAuthoritative) { // We could support this with compile-time string literals, // but it's not yet implemented. throw NotSupportedException(__func__, "assert with strings argument in RepoAuthoritative mode"); } return eval_for_assert(fp, assertion.toString()).toBoolean(); } return assertion.toBoolean(); }(); if (passed) return true; if (!s_option_data->assertCallback.isNull()) { auto const unit = fp->m_func->unit(); ArrayInit ai(3, ArrayInit::vectorInit); ai.set(String(unit->filepath())); ai.set(Variant(unit->getLineNumber(callerOffset))); ai.set(assertion.isString() ? assertion.toString() : String("")); f_call_user_func(1, s_option_data->assertCallback, ai.toArray()); } if (s_option_data->assertWarning) { auto const str = !assertion.isString() ? String("Assertion failed") : concat3("Assertion \"", assertion.toString(), "\" failed"); raise_warning("%s", str.data()); } if (s_option_data->assertBail) { throw Assertion(); } return uninit_null(); }
string make_suffix (string s, string new_suffix) { string new_s; string old_suffix = find_suffix (s); if (old_suffix == NULL) new_s = concat3 (s, ".", new_suffix); else { unsigned length_through_dot = old_suffix - s; new_s = xmalloc (length_through_dot + strlen (new_suffix) + 1); strncpy (new_s, s, length_through_dot); strcpy (new_s + length_through_dot, new_suffix); } return new_s; }