/* Parse all the labels for the VAR_CNT variables in VARS and add the specified labels to those variables. */ static int get_label (struct lexer *lexer, struct variable **vars, size_t var_cnt, const char *dict_encoding) { /* Parse all the labels and add them to the variables. */ do { enum { MAX_LABEL_LEN = 255 }; int width = var_get_width (vars[0]); union value value; struct string label; size_t trunc_len; size_t i; /* Set value. */ value_init (&value, width); if (!parse_value (lexer, &value, vars[0])) { value_destroy (&value, width); return 0; } lex_match (lexer, T_COMMA); /* Set label. */ if (lex_token (lexer) != T_ID && !lex_force_string (lexer)) { value_destroy (&value, width); return 0; } ds_init_substring (&label, lex_tokss (lexer)); trunc_len = utf8_encoding_trunc_len (ds_cstr (&label), dict_encoding, MAX_LABEL_LEN); if (ds_length (&label) > trunc_len) { msg (SW, _("Truncating value label to %d bytes."), MAX_LABEL_LEN); ds_truncate (&label, trunc_len); } for (i = 0; i < var_cnt; i++) var_replace_value_label (vars[i], &value, ds_cstr (&label)); ds_destroy (&label); value_destroy (&value, width); lex_get (lexer); lex_match (lexer, T_COMMA); } while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD); return 1; }
void status_reply_put(struct status_reply *sr, const char *content, ...) { size_t old_length = sr->output.length; size_t added; va_list args; /* Append the status reply to the output. */ ds_put_format(&sr->output, "%s.", sr->category->name); va_start(args, content); ds_put_format_valist(&sr->output, content, args); va_end(args); if (ds_last(&sr->output) != '\n') { ds_put_char(&sr->output, '\n'); } /* Drop what we just added if it doesn't match the request. */ added = sr->output.length - old_length; if (added < sr->request.length || memcmp(&sr->output.string[old_length], sr->request.string, sr->request.length)) { ds_truncate(&sr->output, old_length); } }