Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static int
- handle_dash_c(pl_main_instance_t *pmi, arg_list *pal, char **collected_commands, const char **arg)
- {
- bool ats = pal->expand_ats;
- int code = 0;
- *arg = NULL;
- pal->expand_ats = false;
- while ((code = arg_next(pal, (const char **)arg, pmi->memory)) > 0) {
- size_t arglen;
- if ((*arg)[0] == '@' ||
- ((*arg)[0] == '-' && !isdigit((unsigned char)(*arg)[1]))
- )
- break;
- code = gs_lib_ctx_stash_sanitized_arg(pmi->memory->gs_lib_ctx, "?");
- if (code < 0)
- goto error_exit;
- arglen = strlen(*arg);
- if (*collected_commands == NULL) {
- *collected_commands = (char *)gs_alloc_bytes(pmi->memory, arglen+1,
- "-c buffer");
- if (*collected_commands == NULL) {
- code = gs_note_error(gs_error_VMerror);
- break;
- }
- memcpy(*collected_commands, *arg, arglen+1);
- } else {
- char *newc;
- size_t oldlen = strlen(*collected_commands);
- newc = (char *)gs_resize_object(pmi->memory,
- *collected_commands,
- oldlen + 1 + arglen + 1,
- "-c buffer");
- if (newc == NULL) {
- code = gs_note_error(gs_error_VMerror);
- break;
- }
- newc[oldlen] = 32;
- memcpy(newc + oldlen + 1, *arg, arglen + 1);
- *collected_commands = newc;
- }
- *arg = NULL;
- }
- if (code == gs_error_VMerror)
- dmprintf(pmi->memory, "Failed to allocate memory while handling -c\n");
- else if (code < 0)
- dmprintf(pmi->memory, "Syntax: -c <postscript commands>\n");
- pal->expand_ats = ats;
- return code;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement