"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "wml_backend/p2_mp4h/src/builtin.c" between
wml-2.28.0.tar.xz and wml-2.30.0.tar.xz

About: WML (Website META Language) is an extensible Webdesigner’s off-line HTML generation toolkit.

builtin.c  (wml-2.28.0.tar.xz):builtin.c  (wml-2.30.0.tar.xz)
skipping to change at line 496 skipping to change at line 496
| BP. TRACED defines whether NAME is to be traced. | | BP. TRACED defines whether NAME is to be traced. |
`-------------------------------------------------------------------------*/ `-------------------------------------------------------------------------*/
void void
define_builtin (const char *name, const builtin *bp, bool traced) define_builtin (const char *name, const builtin *bp, bool traced)
{ {
symbol *sym; symbol *sym;
sym = lookup_symbol (name, SYMBOL_INSERT); sym = lookup_symbol (name, SYMBOL_INSERT);
if (SYMBOL_TYPE (sym) == TOKEN_TEXT) if (SYMBOL_TYPE (sym) == TOKEN_TEXT)
xfree ((voidstar) SYMBOL_TEXT (sym)); free ((voidstar) SYMBOL_TEXT (sym));
SYMBOL_TYPE (sym) = TOKEN_FUNC; SYMBOL_TYPE (sym) = TOKEN_FUNC;
SYMBOL_FUNC (sym) = bp->func; SYMBOL_FUNC (sym) = bp->func;
SYMBOL_TRACED (sym) = traced; SYMBOL_TRACED (sym) = traced;
SYMBOL_CONTAINER (sym) = bp->container; SYMBOL_CONTAINER (sym) = bp->container;
SYMBOL_EXPAND_ARGS (sym) = bp->expand_args; SYMBOL_EXPAND_ARGS (sym) = bp->expand_args;
SYMBOL_HOOK_BEGIN (sym) = NULL; SYMBOL_HOOK_BEGIN (sym) = NULL;
SYMBOL_HOOK_END (sym) = NULL; SYMBOL_HOOK_END (sym) = NULL;
} }
/*------------------------------. /*------------------------------.
skipping to change at line 529 skipping to change at line 529
void void
break_init (void) { break_init (void) {
initialize_builtin (&varbreak); initialize_builtin (&varbreak);
SYMBOL_TYPE (&varbreak) = TOKEN_TEXT; SYMBOL_TYPE (&varbreak) = TOKEN_TEXT;
SYMBOL_TEXT (&varbreak) = xstrdup (""); SYMBOL_TEXT (&varbreak) = xstrdup ("");
} }
void void
break_deallocate (void) { break_deallocate (void) {
xfree ((voidstar) SYMBOL_TEXT (&varbreak)); free ((voidstar) SYMBOL_TEXT (&varbreak));
SYMBOL_TYPE (&varbreak) = TOKEN_VOID; SYMBOL_TYPE (&varbreak) = TOKEN_VOID;
} }
/*-------------------------------------------------------------------------. /*-------------------------------------------------------------------------.
| Define a predefined or user-defined macro, with name NAME, and expansion | | Define a predefined or user-defined macro, with name NAME, and expansion |
| TEXT. MODE destinguishes between the "define" and the "pushdef" case. | | TEXT. MODE destinguishes between the "define" and the "pushdef" case. |
| It is also used from main (). | | It is also used from main (). |
`-------------------------------------------------------------------------*/ `-------------------------------------------------------------------------*/
void void
define_user_macro (const char *name, char *text, symbol_lookup mode, define_user_macro (const char *name, char *text, symbol_lookup mode,
bool container, bool expand_args, bool space_delete) bool container, bool expand_args, bool space_delete)
{ {
symbol *s; symbol *s;
char *begin, *cp; char *begin, *cp;
int offset, bracket_level = 0; int offset, bracket_level = 0;
s = lookup_symbol (name, mode); s = lookup_symbol (name, mode);
xfree ((voidstar) SYMBOL_HOOK_BEGIN (s)); free ((voidstar) SYMBOL_HOOK_BEGIN (s));
xfree ((voidstar) SYMBOL_HOOK_END (s)); free ((voidstar) SYMBOL_HOOK_END (s));
if (SYMBOL_TYPE (s) == TOKEN_TEXT) if (SYMBOL_TYPE (s) == TOKEN_TEXT)
xfree ((voidstar) SYMBOL_TEXT (s)); free ((voidstar) SYMBOL_TEXT (s));
initialize_builtin (s); initialize_builtin (s);
SYMBOL_TYPE (s) = TOKEN_TEXT; SYMBOL_TYPE (s) = TOKEN_TEXT;
if (space_delete) if (space_delete)
{ {
for (begin=text; *begin != '\0' && IS_SPACE(*begin); begin++) for (begin=text; *begin != '\0' && IS_SPACE(*begin); begin++)
; ;
SYMBOL_TEXT (s) = xstrdup (begin); SYMBOL_TEXT (s) = xstrdup (begin);
offset = 0; offset = 0;
skipping to change at line 631 skipping to change at line 631
`--------------------------------------------------------------------------*/ `--------------------------------------------------------------------------*/
static void static void
define_user_entity (const char *name, char *text, symbol_lookup mode) define_user_entity (const char *name, char *text, symbol_lookup mode)
{ {
symbol *s; symbol *s;
s = lookup_entity (name, mode); s = lookup_entity (name, mode);
if (SYMBOL_TYPE (s) == TOKEN_TEXT) if (SYMBOL_TYPE (s) == TOKEN_TEXT)
{ {
xfree ((voidstar) SYMBOL_HOOK_BEGIN (s)); free ((voidstar) SYMBOL_HOOK_BEGIN (s));
xfree ((voidstar) SYMBOL_HOOK_END (s)); free ((voidstar) SYMBOL_HOOK_END (s));
xfree ((voidstar) SYMBOL_TEXT (s)); free ((voidstar) SYMBOL_TEXT (s));
} }
initialize_builtin (s); initialize_builtin (s);
SYMBOL_TYPE (s) = TOKEN_TEXT; SYMBOL_TYPE (s) = TOKEN_TEXT;
SYMBOL_TEXT (s) = xstrdup (text); SYMBOL_TEXT (s) = xstrdup (text);
#ifdef DEBUG_INPUT #ifdef DEBUG_INPUT
fprintf (stderr, "Define: %s\nText: %s\n", fprintf (stderr, "Define: %s\nText: %s\n",
SYMBOL_NAME (s), SYMBOL_TEXT (s)); SYMBOL_NAME (s), SYMBOL_TEXT (s));
#endif #endif
} }
/*-----------------------------------------------. /*-----------------------------------------------.
| Initialise all builtin and predefined macros. | | Initialise all builtin and predefined macros. |
`-----------------------------------------------*/ `-----------------------------------------------*/
void void
builtin_init (void) builtin_init (void)
{ {
install_builtin_table (builtin_tab); install_builtin_table (builtin_tab);
pcre_malloc = xmalloc; pcre_malloc = xmalloc;
pcre_free = xfree; pcre_free = free;
} }
/*-----------------------------------------------. /*-----------------------------------------------.
| Deallocate all builtin and predefined macros. | | Deallocate all builtin and predefined macros. |
`-----------------------------------------------*/ `-----------------------------------------------*/
void void
builtin_deallocate (void) builtin_deallocate (void)
{ {
builtin_table *bt, *bt_next; builtin_table *bt, *bt_next;
for (bt = builtin_tables; bt != NULL; ) for (bt = builtin_tables; bt != NULL; )
{ {
bt_next = bt->next; bt_next = bt->next;
xfree ((voidstar) bt); free ((voidstar) bt);
bt = bt_next; bt = bt_next;
} }
varstack_check (); varstack_check ();
} }
static pcre * static pcre *
xre_compile (const char *pattern, int cflags) xre_compile (const char *pattern, int cflags)
{ {
pcre *patcomp; pcre *patcomp;
const char *errbuf; const char *errbuf;
skipping to change at line 827 skipping to change at line 827
for (cp=list; *cp != '\0'; cp++) for (cp=list; *cp != '\0'; cp++)
{ {
if (*cp == ',') if (*cp == ',')
*cp = '|'; *cp = '|';
} }
name = (char *) xmalloc (strlen (list) + 3); name = (char *) xmalloc (strlen (list) + 3);
sprintf (name, "^%s$", list); sprintf (name, "^%s$", list);
/* Compile this expression once */ /* Compile this expression once */
re = xre_compile (name, PCRE_CASELESS); re = xre_compile (name, PCRE_CASELESS);
xfree ((voidstar) name); free ((voidstar) name);
if (re == NULL) if (re == NULL)
return; return;
if (argc>2) if (argc>2)
{ {
re_extra = pcre_study (re, 0, &errptr); re_extra = pcre_study (re, 0, &errptr);
if (errptr != NULL) if (errptr != NULL)
{ {
MP4HERROR ((warning_status, 0, MP4HERROR ((warning_status, 0,
_("Error:%s:%d: Bad regular expression `%s': %s"), _("Error:%s:%d: Bad regular expression `%s': %s"),
skipping to change at line 916 skipping to change at line 916
if (!first) if (!first)
obstack_1grow (obs, ' '); obstack_1grow (obs, ' ');
first = false; first = false;
obstack_1grow (obs, CHAR_BGROUP); obstack_1grow (obs, CHAR_BGROUP);
obstack_grow (obs, ARG (i), strlen (ARG (i))); obstack_grow (obs, ARG (i), strlen (ARG (i)));
obstack_1grow (obs, CHAR_EGROUP); obstack_1grow (obs, CHAR_EGROUP);
} }
} }
pcre_free (re); pcre_free (re);
pcre_free (re_extra); pcre_free (re_extra);
xfree ((voidstar) match_ptr); free ((voidstar) match_ptr);
} }
/* /*
The rest of this file is the code for builtins and expansion of user The rest of this file is the code for builtins and expansion of user
defined macros. All the functions for builtins have a prototype as: defined macros. All the functions for builtins have a prototype as:
void mp4h_bp_MACRONAME ( void mp4h_bp_MACRONAME (
struct obstack *obs, struct obstack *obs,
int argc, int argc,
char *argv[], char *argv[],
skipping to change at line 955 skipping to change at line 955
/* Miscellaneous builtins -- "__file__" and "__line__". */ /* Miscellaneous builtins -- "__file__" and "__line__". */
static void static void
mp4h_bp___file__ (MP4H_BUILTIN_ARGS) mp4h_bp___file__ (MP4H_BUILTIN_ARGS)
{ {
if (argc == 1) if (argc == 1)
shipout_string (obs, current_file, 0); shipout_string (obs, current_file, 0);
else else
{ {
xfree ((voidstar) current_file); free ((voidstar) current_file);
current_file = xstrdup (ARG (1)); current_file = xstrdup (ARG (1));
} }
} }
static void static void
mp4h_bp___line__ (MP4H_BUILTIN_ARGS) mp4h_bp___line__ (MP4H_BUILTIN_ARGS)
{ {
if (argc == 1) if (argc == 1)
shipout_int (obs, current_line); shipout_int (obs, current_line);
else else
skipping to change at line 1293 skipping to change at line 1293
MP4HERROR ((warning_status, 0, MP4HERROR ((warning_status, 0,
"INTERNAL ERROR: Bad symbol type in mp4h_bp_function_def ()")); "INTERNAL ERROR: Bad symbol type in mp4h_bp_function_def ()"));
exit (1); exit (1);
} }
} }
/* file functions */ /* file functions */
#ifdef HAVE_FILE_FUNCS #ifdef HAVE_FILE_FUNCS
/*-----------------------------------------------------------------. /*
| Informations on a file. A newline separated string is printed: | Metadata about a file. A newline separated string is printed:
| Line 1: file size | Line 1: file size
| Line 2: file type | Line 2: file type
| Line 3: time of last change | Line 3: time of last change
| Line 4: time of last modification | Line 4: time of last modification
| Line 5: time of last modification | Line 5: time of last access
| Line 6: time of last access | Line 6: name of the owner of this file
| Line 7: name of the owner of this file | Line 7: name of the group of this file
| Line 8: name of the group of this file | */
`-----------------------------------------------------------------*/
static void static void
mp4h_bp_get_file_properties (MP4H_BUILTIN_ARGS) mp4h_bp_get_file_properties (MP4H_BUILTIN_ARGS)
{ {
struct stat buf; struct stat buf;
struct passwd *user; struct passwd *user;
struct group *group; struct group *group;
CHECK_SAFETY_LEVEL(1); CHECK_SAFETY_LEVEL(1);
if (bad_argc (argv[0], argc, 2, 2)) if (bad_argc (argv[0], argc, 2, 2))
skipping to change at line 1421 skipping to change at line 1420
obstack_1grow (obs, '\n'); obstack_1grow (obs, '\n');
obstack_grow (obs, entry->d_name, length); obstack_grow (obs, entry->d_name, length);
first = false; first = false;
} }
} }
if (matching) if (matching)
{ {
pcre_free (re); pcre_free (re);
pcre_free (re_extra); pcre_free (re_extra);
xfree ((voidstar) match_ptr); free ((voidstar) match_ptr);
} }
closedir (dir); closedir (dir);
} }
/*--------------------------------. /*--------------------------------.
| Returns "true" if file exists. | | Returns "true" if file exists. |
`--------------------------------*/ `--------------------------------*/
static void static void
mp4h_bp_file_exists (MP4H_BUILTIN_ARGS) mp4h_bp_file_exists (MP4H_BUILTIN_ARGS)
{ {
skipping to change at line 1510 skipping to change at line 1509
} }
else else
epoch_time = time ((time_t *)NULL); epoch_time = time ((time_t *)NULL);
timeptr = (struct tm *) localtime (&epoch_time); timeptr = (struct tm *) localtime (&epoch_time);
if (format) if (format)
{ {
ascii_time = (char *)xmalloc(1000); ascii_time = (char *)xmalloc(1000);
strftime(ascii_time, 1000, format, timeptr); strftime(ascii_time, 1000, format, timeptr);
obstack_grow (obs, ascii_time, strlen (ascii_time)); obstack_grow (obs, ascii_time, strlen (ascii_time));
xfree((voidstar) ascii_time); free((voidstar) ascii_time);
} }
else else
{ {
ascii_time = (char *) asctime (timeptr); ascii_time = (char *) asctime (timeptr);
/* Remove newline. */ /* Remove newline. */
LAST_CHAR (ascii_time) = '\0'; LAST_CHAR (ascii_time) = '\0';
obstack_grow (obs, ascii_time, strlen (ascii_time)); obstack_grow (obs, ascii_time, strlen (ascii_time));
} }
} }
skipping to change at line 1778 skipping to change at line 1777
return; return;
/* ``<while test>expr</while>'' is replaced by /* ``<while test>expr</while>'' is replaced by
``<when test>expr<while test>expr</while></when>''. */ ``<when test>expr<while test>expr</while></when>''. */
if (strlen (ARG (1)) > 0) if (strlen (ARG (1)) > 0)
{ {
/* The ``varbreak '' variable is global and modified by <break>. */ /* The ``varbreak '' variable is global and modified by <break>. */
if (strcmp (SYMBOL_TEXT (&varbreak), "true") == 0) if (strcmp (SYMBOL_TEXT (&varbreak), "true") == 0)
{ {
xfree ((voidstar) SYMBOL_TEXT (&varbreak)); free ((voidstar) SYMBOL_TEXT (&varbreak));
SYMBOL_TEXT (&varbreak) = xstrdup (""); SYMBOL_TEXT (&varbreak) = xstrdup ("");
return; return;
} }
obstack_grow (obs, "<when ", 6); obstack_grow (obs, "<when ", 6);
dump_args (obs, argc, argv, " "); dump_args (obs, argc, argv, " ");
obstack_grow (obs, " >", 2); obstack_grow (obs, " >", 2);
obstack_grow (obs, ARGBODY, strlen (ARGBODY)); obstack_grow (obs, ARGBODY, strlen (ARGBODY));
obstack_grow (obs, "<while ", 7); obstack_grow (obs, "<while ", 7);
dump_args (obs, argc, argv, " "); dump_args (obs, argc, argv, " ");
skipping to change at line 1921 skipping to change at line 1920
} }
} }
} }
/*------------------------------------. /*------------------------------------.
| Immediately exits from inner loop. | | Immediately exits from inner loop. |
`------------------------------------*/ `------------------------------------*/
static void static void
mp4h_bp_break (MP4H_BUILTIN_ARGS) mp4h_bp_break (MP4H_BUILTIN_ARGS)
{ {
xfree ((voidstar) SYMBOL_TEXT (&varbreak)); free ((voidstar) SYMBOL_TEXT (&varbreak));
SYMBOL_TEXT (&varbreak) = xstrdup ("true"); SYMBOL_TEXT (&varbreak) = xstrdup ("true");
} }
/*------------------------------------. /*------------------------------------.
| Immediately exits from inner macro. | | Immediately exits from inner macro. |
`------------------------------------*/ `------------------------------------*/
static void static void
mp4h_bp_return (MP4H_BUILTIN_ARGS) mp4h_bp_return (MP4H_BUILTIN_ARGS)
{ {
int i, levels=1; int i, levels=1;
skipping to change at line 2066 skipping to change at line 2065
MP4HERROR ((warning_status, 0, MP4HERROR ((warning_status, 0,
"INTERNAL ERROR: Bad token data type in mp4h_bp_define_tag ()")); "INTERNAL ERROR: Bad token data type in mp4h_bp_define_tag ()"));
exit (1); exit (1);
} }
/* Clear hooks */ /* Clear hooks */
sym = lookup_symbol (ARG (1), SYMBOL_LOOKUP); sym = lookup_symbol (ARG (1), SYMBOL_LOOKUP);
if (!sym) if (!sym)
return; return;
xfree ((voidstar) SYMBOL_HOOK_BEGIN (sym)); free ((voidstar) SYMBOL_HOOK_BEGIN (sym));
xfree ((voidstar) SYMBOL_HOOK_END (sym)); free ((voidstar) SYMBOL_HOOK_END (sym));
} }
/*-------------------------------------. /*-------------------------------------.
| Define tags if not already defined | | Define tags if not already defined |
`-------------------------------------*/ `-------------------------------------*/
static void static void
mp4h_bp_provide_tag (MP4H_BUILTIN_ARGS) mp4h_bp_provide_tag (MP4H_BUILTIN_ARGS)
{ {
symbol *sym; symbol *sym;
skipping to change at line 2201 skipping to change at line 2200
strcpy (text, hook); strcpy (text, hook);
strcat (text, ARGBODY); strcat (text, ARGBODY);
break; break;
default: default:
MP4HERROR ((warning_status, 0, MP4HERROR ((warning_status, 0,
"INTERNAL ERROR: Illegal value in generic_set_hook ()")); "INTERNAL ERROR: Illegal value in generic_set_hook ()"));
exit (1); exit (1);
} }
xfree ((voidstar) hook); free ((voidstar) hook);
if (before) if (before)
SYMBOL_HOOK_BEGIN (sym) = text; SYMBOL_HOOK_BEGIN (sym) = text;
else else
SYMBOL_HOOK_END (sym) = text; SYMBOL_HOOK_END (sym) = text;
} }
static void static void
mp4h_bp_set_hook (MP4H_BUILTIN_ARGS) mp4h_bp_set_hook (MP4H_BUILTIN_ARGS)
{ {
const char *action, *position; const char *action, *position;
skipping to change at line 2359 skipping to change at line 2358
if (argc == 1) if (argc == 1)
define_user_entity (ARG (1), "", SYMBOL_INSERT); define_user_entity (ARG (1), "", SYMBOL_INSERT);
else else
define_user_entity (ARG (1), ARGBODY, SYMBOL_INSERT); define_user_entity (ARG (1), ARGBODY, SYMBOL_INSERT);
/* Clear hooks */ /* Clear hooks */
sym = lookup_entity (ARG (1), SYMBOL_LOOKUP); sym = lookup_entity (ARG (1), SYMBOL_LOOKUP);
if (!sym) if (!sym)
return; return;
xfree ((voidstar) SYMBOL_HOOK_BEGIN (sym)); free ((voidstar) SYMBOL_HOOK_BEGIN (sym));
xfree ((voidstar) SYMBOL_HOOK_END (sym)); free ((voidstar) SYMBOL_HOOK_END (sym));
} }
/* Math functions */ /* Math functions */
/*--------------------------------------------------. /*--------------------------------------------------.
| This function is called by relational operators. | | This function is called by relational operators. |
| These operators are binary operators, operands | | These operators are binary operators, operands |
| are either numbers or variable names. | | are either numbers or variable names. |
`--------------------------------------------------*/ `--------------------------------------------------*/
static void static void
skipping to change at line 2724 skipping to change at line 2723
} }
return; return;
} }
} }
push_file (fp, filename); push_file (fp, filename);
if (verbatim && strcmp (verbatim, "true") == 0) if (verbatim && strcmp (verbatim, "true") == 0)
read_file_verbatim (obs); read_file_verbatim (obs);
xfree ((voidstar) filename); free ((voidstar) filename);
} }
/*-------------------------------------------------. /*-------------------------------------------------.
| Transform a module or library name foo:bar into | | Transform a module or library name foo:bar into |
| physical path `foo/bar'. | | physical path `foo/bar'. |
`-------------------------------------------------*/ `-------------------------------------------------*/
static void static void
logical_to_physical_paths (char **name) logical_to_physical_paths (char **name)
{ {
register char *cp; register char *cp;
skipping to change at line 2784 skipping to change at line 2783
real_filename = xmalloc (strlen (name) + 7); real_filename = xmalloc (strlen (name) + 7);
sprintf (real_filename, "%s.mp4hp", name); sprintf (real_filename, "%s.mp4hp", name);
logical_to_physical_paths (&real_filename); logical_to_physical_paths (&real_filename);
fp = path_search (real_filename, &filename); fp = path_search (real_filename, &filename);
if (fp == NULL) if (fp == NULL)
{ {
MP4HERROR ((warning_status, errno, MP4HERROR ((warning_status, errno,
_("Warning:%s:%d: Cannot open %s"), _("Warning:%s:%d: Cannot open %s"),
CURRENT_FILE_LINE, name)); CURRENT_FILE_LINE, name));
xfree ((voidstar) real_filename); free ((voidstar) real_filename);
return; return;
} }
else else
if (debug_level & DEBUG_TRACE_MODULES) if (debug_level & DEBUG_TRACE_MODULES)
DEBUG_MESSAGE2("module `%s': loaded ok (=%s)", name, filename); DEBUG_MESSAGE2("module `%s': loaded ok (=%s)", name, filename);
lookup_file (name, SYMBOL_INSERT); lookup_file (name, SYMBOL_INSERT);
push_file (fp, filename); push_file (fp, filename);
xfree ((voidstar) filename); free ((voidstar) filename);
} }
/*-------------------------------------. /*-------------------------------------.
| Loading external module at runtime. | | Loading external module at runtime. |
`-------------------------------------*/ `-------------------------------------*/
#ifdef WITH_MODULES #ifdef WITH_MODULES
static void static void
mp4h_bp_load (MP4H_BUILTIN_ARGS) mp4h_bp_load (MP4H_BUILTIN_ARGS)
{ {
skipping to change at line 2822 skipping to change at line 2821
MP4HERROR ((warning_status, 0, MP4HERROR ((warning_status, 0,
_("Error:%s:%d: In <%s>, at least one of '%s' and '%s' attributes must b e specified"), _("Error:%s:%d: In <%s>, at least one of '%s' and '%s' attributes must b e specified"),
CURRENT_FILE_LINE, ARG (0), "module", "library")); CURRENT_FILE_LINE, ARG (0), "module", "library"));
return; return;
} }
if (library) if (library)
{ {
realname = xstrdup (library); realname = xstrdup (library);
logical_to_physical_paths (&realname); logical_to_physical_paths (&realname);
library_load (realname, obs); library_load (realname, obs);
xfree ((voidstar) realname); free ((voidstar) realname);
} }
if (module) if (module)
{ {
realname = xstrdup (module); realname = xstrdup (module);
logical_to_physical_paths (&realname); logical_to_physical_paths (&realname);
module_load (realname, obs); module_load (realname, obs);
xfree ((voidstar) realname); free ((voidstar) realname);
} }
} }
#endif #endif
/*-----------------------------. /*-----------------------------.
| Discards its body contents. | | Discards its body contents. |
`-----------------------------*/ `-----------------------------*/
static void static void
mp4h_bp_comment (MP4H_BUILTIN_ARGS) mp4h_bp_comment (MP4H_BUILTIN_ARGS)
{ {
} }
/*----------------------------. /*----------------------------.
| Set EOL comment delimiter. | | Set EOL comment delimiter. |
`----------------------------*/ `----------------------------*/
static void static void
mp4h_bp_set_eol_comment (MP4H_BUILTIN_ARGS) mp4h_bp_set_eol_comment (MP4H_BUILTIN_ARGS)
{ {
bad_argc (argv[0], argc, 0, 2); bad_argc (argv[0], argc, 0, 2);
xfree ((voidstar) eolcomm.string); free ((voidstar) eolcomm.string);
eolcomm.string = xstrdup (ARG (1)); eolcomm.string = xstrdup (ARG (1));
eolcomm.length = strlen (eolcomm.string); eolcomm.length = strlen (eolcomm.string);
} }
/*--------------------------------. /*--------------------------------.
| Set quotes to disable parsing. | | Set quotes to disable parsing. |
`--------------------------------*/ `--------------------------------*/
static void static void
mp4h_bp_set_quotes (MP4H_BUILTIN_ARGS) mp4h_bp_set_quotes (MP4H_BUILTIN_ARGS)
{ {
const char *display; const char *display;
display = predefined_attribute ("display", &argc, argv, true); display = predefined_attribute ("display", &argc, argv, true);
visible_quotes = (display && strcmp (display, "visible") == 0); visible_quotes = (display && strcmp (display, "visible") == 0);
if (argc == 1) if (argc == 1)
{ {
xfree ((voidstar) lquote.string); free ((voidstar) lquote.string);
xfree ((voidstar) rquote.string); free ((voidstar) rquote.string);
lquote.string = NULL; lquote.string = NULL;
lquote.length = 0; lquote.length = 0;
rquote.string = NULL; rquote.string = NULL;
rquote.length = 0; rquote.length = 0;
} }
else if (argc == 3) else if (argc == 3)
{ {
if (*ARG (1) != '<' || LAST_CHAR (ARG (2)) != '>') if (*ARG (1) != '<' || LAST_CHAR (ARG (2)) != '>')
{ {
MP4HERROR ((warning_status, 0, MP4HERROR ((warning_status, 0,
_("Warning:%s:%d: <%s> ignored, invalid arguments: %s %s"), _("Warning:%s:%d: <%s> ignored, invalid arguments: %s %s"),
CURRENT_FILE_LINE, ARG (0), ARG (1), ARG (2))); CURRENT_FILE_LINE, ARG (0), ARG (1), ARG (2)));
return; return;
} }
xfree ((voidstar) lquote.string); free ((voidstar) lquote.string);
xfree ((voidstar) rquote.string); free ((voidstar) rquote.string);
lquote.string = xstrdup (ARG (1)); lquote.string = xstrdup (ARG (1));
lquote.length = strlen (lquote.string); lquote.length = strlen (lquote.string);
rquote.string = xstrdup (ARG (2)); rquote.string = xstrdup (ARG (2));
rquote.length = strlen (rquote.string); rquote.length = strlen (rquote.string);
} }
else else
MP4HERROR ((warning_status, 0, MP4HERROR ((warning_status, 0,
_("Warning:%s:%d: `<%s>' must have 0 or 2 arguments, but got %d"), _("Warning:%s:%d: `<%s>' must have 0 or 2 arguments, but got %d"),
CURRENT_FILE_LINE, ARG (0), argc-1)); CURRENT_FILE_LINE, ARG (0), argc-1));
skipping to change at line 3043 skipping to change at line 3042
{ {
for (cp = text; *cp != '\0'; cp++) for (cp = text; *cp != '\0'; cp++)
*cp = toupper (*cp); *cp = toupper (*cp);
} }
else else
{ {
for (cp = text; *cp != '\0'; cp++) for (cp = text; *cp != '\0'; cp++)
*cp = tolower (*cp); *cp = tolower (*cp);
} }
obstack_grow (obs, text, strlen (text)); obstack_grow (obs, text, strlen (text));
xfree ((voidstar) text); free ((voidstar) text);
} }
} }
static void static void
mp4h_bp_downcase (MP4H_BUILTIN_ARGS) mp4h_bp_downcase (MP4H_BUILTIN_ARGS)
{ {
updowncase (obs, argc, argv, false); updowncase (obs, argc, argv, false);
} }
static void static void
skipping to change at line 3087 skipping to change at line 3086
for (cp = text; *cp != '\0'; cp++) for (cp = text; *cp != '\0'; cp++)
{ {
if (next) if (next)
*cp = toupper (*cp); *cp = toupper (*cp);
if (isspace (*cp)) if (isspace (*cp))
next = true; next = true;
else else
next = false; next = false;
} }
obstack_grow (obs, text, strlen (text)); obstack_grow (obs, text, strlen (text));
xfree ((voidstar) text); free ((voidstar) text);
} }
} }
/*---------------------------------------------------------------. /*---------------------------------------------------------------.
| Extracts some portion of a string. Optional attributes are | | Extracts some portion of a string. Optional attributes are |
| start and end position. Zero is the position of the first | | start and end position. Zero is the position of the first |
| character. | | character. |
`---------------------------------------------------------------*/ `---------------------------------------------------------------*/
static void static void
mp4h_bp_substring (MP4H_BUILTIN_ARGS) mp4h_bp_substring (MP4H_BUILTIN_ARGS)
skipping to change at line 3557 skipping to change at line 3556
if (startpos >= 0) if (startpos >= 0)
obstack_grow (obs, ARG (1) + startpos, match_length); obstack_grow (obs, ARG (1) + startpos, match_length);
} }
else else
{ {
if (startpos >= 0) if (startpos >= 0)
obstack_grow (obs, "true", 4); obstack_grow (obs, "true", 4);
} }
pcre_free (re); pcre_free (re);
xfree ((voidstar) match_ptr); free ((voidstar) match_ptr);
} }
/*----------------------------------------------. /*----------------------------------------------.
| Substitutes regular expressions in a string. | | Substitutes regular expressions in a string. |
| A string is returned. | | A string is returned. |
`----------------------------------------------*/ `----------------------------------------------*/
static void static void
subst_in_string (struct obstack *obs, int argc, token_data **argv, subst_in_string (struct obstack *obs, int argc, token_data **argv,
int extra_re_flags) int extra_re_flags)
{ {
skipping to change at line 3662 skipping to change at line 3661
matched a null string, advance offset one more, to avoid matched a null string, advance offset one more, to avoid
infinite loops. */ infinite loops. */
offset += match_ptr[1]; offset += match_ptr[1];
if (match_ptr[0] == match_ptr[1]) if (match_ptr[0] == match_ptr[1])
obstack_1grow (obs, victim[offset++]); obstack_1grow (obs, victim[offset++]);
} }
pcre_free (re); pcre_free (re);
pcre_free (re_extra); pcre_free (re_extra);
xfree ((voidstar) match_ptr); free ((voidstar) match_ptr);
} }
/*------------------------------------------------. /*------------------------------------------------.
| Routine parsing attributes to set regex flags. | | Routine parsing attributes to set regex flags. |
`------------------------------------------------*/ `------------------------------------------------*/
static int static int
regex_attributes (int *ptr_argc, token_data **argv) regex_attributes (int *ptr_argc, token_data **argv)
{ {
const char *singleline, *caseless, *reflags; const char *singleline, *caseless, *reflags;
const char *cp; const char *cp;
skipping to change at line 3753 skipping to change at line 3752
TOKEN_DATA_TYPE (&td) = TOKEN_TEXT; TOKEN_DATA_TYPE (&td) = TOKEN_TEXT;
TOKEN_DATA_TEXT (&td) = SYMBOL_TEXT (var); TOKEN_DATA_TEXT (&td) = SYMBOL_TEXT (var);
obstack_init (&temp_obs); obstack_init (&temp_obs);
argv[1] = &td; argv[1] = &td;
subst_in_string (&temp_obs, argc, argv, extra_re_flags); subst_in_string (&temp_obs, argc, argv, extra_re_flags);
obstack_1grow (&temp_obs, '\0'); obstack_1grow (&temp_obs, '\0');
text = obstack_finish (&temp_obs); text = obstack_finish (&temp_obs);
xfree ((voidstar) SYMBOL_TEXT (var)); free ((voidstar) SYMBOL_TEXT (var));
SYMBOL_TEXT (var) = xstrdup (text); SYMBOL_TEXT (var) = xstrdup (text);
obstack_free (&temp_obs, NULL); obstack_free (&temp_obs, NULL);
} }
/*-------------------------------------------------------------------. /*-------------------------------------------------------------------.
| This function compares a string and a regular expression. | | This function compares a string and a regular expression. |
| Attribute ``action'' can be | | Attribute ``action'' can be |
| report : returns "true" if string match the regular expression. | | report : returns "true" if string match the regular expression. |
| extract : returns the portion of the string matched by the | | extract : returns the portion of the string matched by the |
| regular expression. | | regular expression. |
skipping to change at line 3904 skipping to change at line 3903
if (name == NULL) if (name == NULL)
{ {
MP4HERROR ((warning_status, 0, MP4HERROR ((warning_status, 0,
_("Error:%s:%d: In <%s>, required attribute `%s' is not specified"), _("Error:%s:%d: In <%s>, required attribute `%s' is not specified"),
CURRENT_FILE_LINE, ARG (0), "name")); CURRENT_FILE_LINE, ARG (0), "name"));
return; return;
} }
var = lookup_variable (name, SYMBOL_INSERT); var = lookup_variable (name, SYMBOL_INSERT);
if (SYMBOL_TYPE (var) == TOKEN_TEXT) if (SYMBOL_TYPE (var) == TOKEN_TEXT)
xfree ((voidstar) SYMBOL_TEXT (var)); free ((voidstar) SYMBOL_TEXT (var));
SYMBOL_TEXT (var) = xstrdup (ARGBODY); SYMBOL_TEXT (var) = xstrdup (ARGBODY);
SYMBOL_TYPE (var) = TOKEN_TEXT; SYMBOL_TYPE (var) = TOKEN_TEXT;
} }
/*----------------------------------------------------------------------. /*----------------------------------------------------------------------.
| Define a variable. Argument is evaluated or not depending on whether | | Define a variable. Argument is evaluated or not depending on whether |
| the 'expand attributes' flag is on in the builtin_tab above. | | the 'expand attributes' flag is on in the builtin_tab above. |
`----------------------------------------------------------------------*/ `----------------------------------------------------------------------*/
static void static void
mp4h_bp_set_var (MP4H_BUILTIN_ARGS) mp4h_bp_set_var (MP4H_BUILTIN_ARGS)
skipping to change at line 4005 skipping to change at line 4004
} }
} }
} }
} }
var = lookup_variable (ARG (i), SYMBOL_INSERT); var = lookup_variable (ARG (i), SYMBOL_INSERT);
if (ptr_index == NULL) if (ptr_index == NULL)
{ {
/* single value. */ /* single value. */
if (SYMBOL_TYPE (var) == TOKEN_TEXT) if (SYMBOL_TYPE (var) == TOKEN_TEXT)
xfree ((voidstar) SYMBOL_TEXT (var)); free ((voidstar) SYMBOL_TEXT (var));
SYMBOL_TEXT (var) = xstrdup (value); SYMBOL_TEXT (var) = xstrdup (value);
} }
else if (array_index >= 0) else if (array_index >= 0)
{ {
/* an index has been specified. */ /* an index has been specified. */
if (SYMBOL_TYPE (var) == TOKEN_TEXT) if (SYMBOL_TYPE (var) == TOKEN_TEXT)
old_value = SYMBOL_TEXT (var); old_value = SYMBOL_TEXT (var);
else else
old_value = ""; old_value = "";
skipping to change at line 4051 skipping to change at line 4050
cp = array_value (var, array_index, 0); cp = array_value (var, array_index, 0);
strncat (new_value, old_value, cp - SYMBOL_TEXT (var)); strncat (new_value, old_value, cp - SYMBOL_TEXT (var));
strcat (new_value, value); strcat (new_value, value);
cp = strchr (cp, '\n'); cp = strchr (cp, '\n');
if (cp) if (cp)
strcat (new_value, cp); strcat (new_value, cp);
} }
} }
if (SYMBOL_TYPE (var) == TOKEN_TEXT) if (SYMBOL_TYPE (var) == TOKEN_TEXT)
xfree ((voidstar) SYMBOL_TEXT (var)); free ((voidstar) SYMBOL_TEXT (var));
SYMBOL_TEXT (var) = new_value; SYMBOL_TEXT (var) = new_value;
} }
SYMBOL_TYPE (var) = TOKEN_TEXT; SYMBOL_TYPE (var) = TOKEN_TEXT;
i += istep; i += istep;
} }
} }
/*------------------------------. /*------------------------------.
| Get the value of a variable. | | Get the value of a variable. |
skipping to change at line 4145 skipping to change at line 4144
var = lookup_variable (ARG (i), SYMBOL_INSERT); var = lookup_variable (ARG (i), SYMBOL_INSERT);
if (!vs) if (!vs)
{ {
MP4HERROR ((warning_status, 0, _("\ MP4HERROR ((warning_status, 0, _("\
Warning:%s:%d: Variable stack empty, it means <%s> already gobbled all data"), Warning:%s:%d: Variable stack empty, it means <%s> already gobbled all data"),
CURRENT_FILE_LINE, ARG (0))); CURRENT_FILE_LINE, ARG (0)));
return; return;
} }
if (SYMBOL_TYPE (var) == TOKEN_TEXT) if (SYMBOL_TYPE (var) == TOKEN_TEXT)
xfree ((voidstar) SYMBOL_TEXT (var)); free ((voidstar) SYMBOL_TEXT (var));
SYMBOL_TEXT (var) = xstrdup (vs->text); SYMBOL_TEXT (var) = xstrdup (vs->text);
SYMBOL_TYPE (var) = TOKEN_TEXT; SYMBOL_TYPE (var) = TOKEN_TEXT;
prev = vs->prev; prev = vs->prev;
xfree ((voidstar) vs->text); free ((voidstar) vs->text);
xfree ((voidstar) vs); free ((voidstar) vs);
vs = prev; vs = prev;
} }
} }
static void static void
varstack_check (void) varstack_check (void)
{ {
if (vs) if (vs)
{ {
MP4HERROR ((warning_status, 0, _("\ MP4HERROR ((warning_status, 0, _("\
skipping to change at line 4210 skipping to change at line 4209
var = lookup_variable (ARG (1), SYMBOL_LOOKUP); var = lookup_variable (ARG (1), SYMBOL_LOOKUP);
if (var == NULL) if (var == NULL)
return; return;
if (!numeric_arg (argv[0], SYMBOL_TEXT (var), true, &value)) if (!numeric_arg (argv[0], SYMBOL_TEXT (var), true, &value))
return; return;
if (!numeric_arg (argv[0], by, true, &incr)) if (!numeric_arg (argv[0], by, true, &incr))
return; return;
if (SYMBOL_TYPE (var) == TOKEN_TEXT) if (SYMBOL_TYPE (var) == TOKEN_TEXT)
xfree ((voidstar) SYMBOL_TEXT (var)); free ((voidstar) SYMBOL_TEXT (var));
sprintf (buf, "%d", value+incr); sprintf (buf, "%d", value+incr);
SYMBOL_TEXT (var) = xstrdup(buf); SYMBOL_TEXT (var) = xstrdup(buf);
} }
static void static void
mp4h_bp_decrement (MP4H_BUILTIN_ARGS) mp4h_bp_decrement (MP4H_BUILTIN_ARGS)
{ {
int value, incr; int value, incr;
symbol *var; symbol *var;
skipping to change at line 4243 skipping to change at line 4242
var = lookup_variable (ARG (1), SYMBOL_LOOKUP); var = lookup_variable (ARG (1), SYMBOL_LOOKUP);
if (var == NULL) if (var == NULL)
return; return;
if (!numeric_arg (argv[0], SYMBOL_TEXT (var), true, &value)) if (!numeric_arg (argv[0], SYMBOL_TEXT (var), true, &value))
return; return;
if (!numeric_arg (argv[0], by, true, &incr)) if (!numeric_arg (argv[0], by, true, &incr))
return; return;
if (SYMBOL_TYPE (var) == TOKEN_TEXT) if (SYMBOL_TYPE (var) == TOKEN_TEXT)
xfree ((voidstar) SYMBOL_TEXT (var)); free ((voidstar) SYMBOL_TEXT (var));
sprintf (buf, "%d", value-incr); sprintf (buf, "%d", value-incr);
SYMBOL_TEXT (var) = xstrdup(buf); SYMBOL_TEXT (var) = xstrdup(buf);
} }
/*--------------------------------. /* Dumps information about symbols. */
| Dumps informations of symbols. |
`--------------------------------*/
static void static void
mp4h_bp_symbol_info (MP4H_BUILTIN_ARGS) mp4h_bp_symbol_info (MP4H_BUILTIN_ARGS)
{ {
symbol *var; symbol *var;
int size; int size;
if (bad_argc (argv[0], argc, 0, 2)) if (bad_argc (argv[0], argc, 0, 2))
return; return;
/* First look if this variable is defined. */ /* First look if this variable is defined. */
skipping to change at line 4314 skipping to change at line 4311
var1 = lookup_variable (ARG (1), SYMBOL_LOOKUP); var1 = lookup_variable (ARG (1), SYMBOL_LOOKUP);
if (var1 == NULL) if (var1 == NULL)
{ {
MP4HERROR ((warning_status, 0, MP4HERROR ((warning_status, 0,
_("Warning:%s:%d: Variable `%s' not defined in <%s>"), _("Warning:%s:%d: Variable `%s' not defined in <%s>"),
CURRENT_FILE_LINE, ARG (1), ARG (0))); CURRENT_FILE_LINE, ARG (1), ARG (0)));
return; return;
} }
var2 = lookup_variable (ARG (2), SYMBOL_INSERT); var2 = lookup_variable (ARG (2), SYMBOL_INSERT);
if (SYMBOL_TYPE (var2) == TOKEN_TEXT) if (SYMBOL_TYPE (var2) == TOKEN_TEXT)
xfree ((voidstar) SYMBOL_TEXT (var2)); free ((voidstar) SYMBOL_TEXT (var2));
SYMBOL_TEXT (var2) = xstrdup(SYMBOL_TEXT (var1)); SYMBOL_TEXT (var2) = xstrdup(SYMBOL_TEXT (var1));
SYMBOL_TYPE (var2) = TOKEN_TEXT; SYMBOL_TYPE (var2) = TOKEN_TEXT;
} }
/*--------------------------------. /*--------------------------------.
| Defines a variable only if it | | Defines a variable only if it |
| is not set yet. | | is not set yet. |
`--------------------------------*/ `--------------------------------*/
static void static void
skipping to change at line 4341 skipping to change at line 4338
var = lookup_variable (ARG (1), SYMBOL_LOOKUP); var = lookup_variable (ARG (1), SYMBOL_LOOKUP);
if (var == NULL) if (var == NULL)
{ {
var = lookup_variable (ARG (1), SYMBOL_INSERT); var = lookup_variable (ARG (1), SYMBOL_INSERT);
SYMBOL_TYPE (var) = TOKEN_TEXT; SYMBOL_TYPE (var) = TOKEN_TEXT;
SYMBOL_TEXT (var) = xstrdup(ARG (2)); SYMBOL_TEXT (var) = xstrdup(ARG (2));
} }
else if (SYMBOL_TYPE (var) == TOKEN_TEXT && *(SYMBOL_TEXT (var)) == '\0') else if (SYMBOL_TYPE (var) == TOKEN_TEXT && *(SYMBOL_TEXT (var)) == '\0')
{ {
xfree ((voidstar) SYMBOL_TEXT (var)); free ((voidstar) SYMBOL_TEXT (var));
SYMBOL_TEXT (var) = xstrdup(ARG (2)); SYMBOL_TEXT (var) = xstrdup(ARG (2));
} }
} }
/* Array functions: */ /* Array functions: */
/*------------------------------------------------------------. /*------------------------------------------------------------.
| An array is a representation of variables, it is a newline | | An array is a representation of variables, it is a newline |
| separated list of strings. | | separated list of strings. |
`------------------------------------------------------------*/ `------------------------------------------------------------*/
skipping to change at line 4462 skipping to change at line 4459
if (caseless) if (caseless)
found = (strcasecmp (cp, text) == 0); found = (strcasecmp (cp, text) == 0);
else else
found = (strcmp (cp, text) == 0); found = (strcmp (cp, text) == 0);
if (next_item == NULL || found) if (next_item == NULL || found)
break; break;
cp = next_item + 1; cp = next_item + 1;
} }
xfree ((voidstar) value); free ((voidstar) value);
if (found) if (found)
return result; return result;
else else
return -1; return -1;
} }
static void static void
mp4h_bp_array_member (MP4H_BUILTIN_ARGS) mp4h_bp_array_member (MP4H_BUILTIN_ARGS)
{ {
skipping to change at line 4521 skipping to change at line 4518
SYMBOL_TEXT (var) = xstrdup (ARG (2)); SYMBOL_TEXT (var) = xstrdup (ARG (2));
SYMBOL_TYPE (var) = TOKEN_TEXT; SYMBOL_TYPE (var) = TOKEN_TEXT;
} }
else else
{ {
exists = array_member (ARG (2), var, (caseless != NULL)); exists = array_member (ARG (2), var, (caseless != NULL));
if (exists == -1) if (exists == -1)
{ {
value = (char *) xmalloc (strlen (SYMBOL_TEXT (var)) + strlen (ARG (2) ) + 2); value = (char *) xmalloc (strlen (SYMBOL_TEXT (var)) + strlen (ARG (2) ) + 2);
sprintf (value, "%s\n%s", SYMBOL_TEXT (var), ARG (2)); sprintf (value, "%s\n%s", SYMBOL_TEXT (var), ARG (2));
xfree ((voidstar) SYMBOL_TEXT (var)); free ((voidstar) SYMBOL_TEXT (var));
SYMBOL_TEXT (var) = xstrdup (value); SYMBOL_TEXT (var) = xstrdup (value);
xfree ((voidstar) value); free ((voidstar) value);
} }
} }
} }
/*------------------------------. /*------------------------------.
| Adds an element to an array. | | Adds an element to an array. |
`------------------------------*/ `------------------------------*/
static void static void
mp4h_bp_array_push (MP4H_BUILTIN_ARGS) mp4h_bp_array_push (MP4H_BUILTIN_ARGS)
{ {
skipping to change at line 4550 skipping to change at line 4547
var = lookup_variable (ARG (1), SYMBOL_INSERT); var = lookup_variable (ARG (1), SYMBOL_INSERT);
if (SYMBOL_TYPE (var) != TOKEN_TEXT) if (SYMBOL_TYPE (var) != TOKEN_TEXT)
{ {
SYMBOL_TEXT (var) = xstrdup (ARG (2)); SYMBOL_TEXT (var) = xstrdup (ARG (2));
SYMBOL_TYPE (var) = TOKEN_TEXT; SYMBOL_TYPE (var) = TOKEN_TEXT;
} }
else else
{ {
if (*(SYMBOL_TEXT (var)) == '\0') if (*(SYMBOL_TEXT (var)) == '\0')
{ {
xfree ((voidstar) SYMBOL_TEXT (var)); free ((voidstar) SYMBOL_TEXT (var));
SYMBOL_TEXT (var) = xstrdup (ARG (2)); SYMBOL_TEXT (var) = xstrdup (ARG (2));
} }
else else
{ {
old_value = (char *) xmalloc (strlen (SYMBOL_TEXT (var)) + strlen (ARG (2)) + 2); old_value = (char *) xmalloc (strlen (SYMBOL_TEXT (var)) + strlen (ARG (2)) + 2);
sprintf (old_value, "%s\n%s", SYMBOL_TEXT (var), ARG (2)); sprintf (old_value, "%s\n%s", SYMBOL_TEXT (var), ARG (2));
xfree ((voidstar) SYMBOL_TEXT (var)); free ((voidstar) SYMBOL_TEXT (var));
SYMBOL_TEXT (var) = old_value; SYMBOL_TEXT (var) = old_value;
} }
} }
} }
/*---------------------------------------------------------. /*---------------------------------------------------------.
| Remove the top level value from an array and return it. | | Remove the top level value from an array and return it. |
`---------------------------------------------------------*/ `---------------------------------------------------------*/
static void static void
mp4h_bp_array_pop (MP4H_BUILTIN_ARGS) mp4h_bp_array_pop (MP4H_BUILTIN_ARGS)
skipping to change at line 4696 skipping to change at line 4693
*(cp+offset) = '\0'; *(cp+offset) = '\0';
strcpy ((char *) (cp+offset), old_value); strcpy ((char *) (cp+offset), old_value);
} }
else else
{ {
old_value = array_value (var, ind_start-offset, 0); old_value = array_value (var, ind_start-offset, 0);
if (!old_value) if (!old_value)
return; return;
strcpy ((char *) cp, old_value); strcpy ((char *) cp, old_value);
} }
xfree ((voidstar) SYMBOL_TEXT (var)); free ((voidstar) SYMBOL_TEXT (var));
SYMBOL_TEXT (var) = value; SYMBOL_TEXT (var) = value;
} }
/*------------------------------. /*------------------------------.
| Concatenate multiple arrays. | | Concatenate multiple arrays. |
`------------------------------*/ `------------------------------*/
static void static void
mp4h_bp_array_concat (MP4H_BUILTIN_ARGS) mp4h_bp_array_concat (MP4H_BUILTIN_ARGS)
{ {
symbol *var, *varadd; symbol *var, *varadd;
skipping to change at line 4731 skipping to change at line 4728
{ {
varadd = lookup_variable (ARG (i), SYMBOL_LOOKUP); varadd = lookup_variable (ARG (i), SYMBOL_LOOKUP);
if (varadd == NULL) if (varadd == NULL)
continue; continue;
if (SYMBOL_TYPE (varadd) != TOKEN_TEXT) if (SYMBOL_TYPE (varadd) != TOKEN_TEXT)
continue; continue;
value = (char *) xmalloc (strlen (SYMBOL_TEXT (var)) + value = (char *) xmalloc (strlen (SYMBOL_TEXT (var)) +
strlen (SYMBOL_TEXT (varadd)) + 2); strlen (SYMBOL_TEXT (varadd)) + 2);
sprintf (value, "%s\n%s", SYMBOL_TEXT (var), SYMBOL_TEXT (varadd)); sprintf (value, "%s\n%s", SYMBOL_TEXT (var), SYMBOL_TEXT (varadd));
xfree ((voidstar) SYMBOL_TEXT (var)); free ((voidstar) SYMBOL_TEXT (var));
SYMBOL_TEXT (var) = xstrdup (value); SYMBOL_TEXT (var) = xstrdup (value);
xfree ((voidstar) value); free ((voidstar) value);
} }
} }
/*---------------------------------------------------------------------. /*---------------------------------------------------------------------.
| This function is used to sort arrays. Arguments are either strings | | This function is used to sort arrays. Arguments are either strings |
| or numerical values. | | or numerical values. |
`---------------------------------------------------------------------*/ `---------------------------------------------------------------------*/
static int static int
sort_function (const void *item1, const void *item2) sort_function (const void *item1, const void *item2)
{ {
skipping to change at line 4833 skipping to change at line 4830
} }
qsort ((void *)array, size, sizeof (char *), sort_function); qsort ((void *)array, size, sizeof (char *), sort_function);
strcpy (SYMBOL_TEXT (var), array[0]); strcpy (SYMBOL_TEXT (var), array[0]);
for (i=1; i<size; i++) for (i=1; i<size; i++)
{ {
strcat (SYMBOL_TEXT (var), "\n"); strcat (SYMBOL_TEXT (var), "\n");
strcat (SYMBOL_TEXT (var), array[i]); strcat (SYMBOL_TEXT (var), array[i]);
} }
xfree ((voidstar) array); free ((voidstar) array);
xfree ((voidstar) value); free ((voidstar) value);
} }
/* This section contains the macros "divert", "undivert" and "divnum" for /* This section contains the macros "divert", "undivert" and "divnum" for
handling diversion. The utility functions used lives in output.c. */ handling diversion. The utility functions used lives in output.c. */
/*-----------------------------------------------------------------------. /*-----------------------------------------------------------------------.
| Divert further output to the diversion given by ARGV[1]. Out of range | | Divert further output to the diversion given by ARGV[1]. Out of range |
| means discard further output. | | means discard further output. |
`-----------------------------------------------------------------------*/ `-----------------------------------------------------------------------*/
 End of changes. 50 change blocks. 
71 lines changed or deleted 68 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)