MCPcopy Create free account
hub / github.com/Entware/Entware / expr_print_gstr_helper

Function expr_print_gstr_helper

scripts/config/expr.c:1240–1268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1238}
1239
1240static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *str)
1241{
1242 struct gstr *gs = (struct gstr*)data;
1243 const char *sym_str = NULL;
1244
1245 if (sym)
1246 sym_str = sym_get_string_value(sym);
1247
1248 if (gs->max_width) {
1249 unsigned extra_length = strlen(str);
1250 const char *last_cr = strrchr(gs->s, '\n');
1251 unsigned last_line_length;
1252
1253 if (sym_str)
1254 extra_length += 4 + strlen(sym_str);
1255
1256 if (!last_cr)
1257 last_cr = gs->s;
1258
1259 last_line_length = strlen(gs->s) - (last_cr - gs->s);
1260
1261 if ((last_line_length + extra_length) > gs->max_width)
1262 str_append(gs, "\\\n");
1263 }
1264
1265 str_append(gs, str);
1266 if (sym && sym->type != S_UNKNOWN)
1267 str_printf(gs, " [=%s]", sym_str);
1268}
1269
1270void expr_gstr_print(struct expr *e, struct gstr *gs)
1271{

Callers

nothing calls this directly

Calls 3

sym_get_string_valueFunction · 0.85
str_appendFunction · 0.85
str_printfFunction · 0.85

Tested by

no test coverage detected