]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/captoinfo.c
ncurses 5.0
[ncurses.git] / ncurses / tinfo / captoinfo.c
similarity index 98%
rename from ncurses/captoinfo.c
rename to ncurses/tinfo/captoinfo.c
index 387fabd36888db434db4e0fd8c5a9a50d10ca731..d0881ecd47921728fa1aaf8435a4fd80212c7af5 100644 (file)
@@ -94,7 +94,7 @@
 #include <ctype.h>
 #include <tic.h>
 
-MODULE_ID("$Id: captoinfo.c,v 1.17 1998/02/11 12:13:54 tom Exp $")
+MODULE_ID("$Id: captoinfo.c,v 1.24 1999/07/24 20:06:13 tom Exp $")
 
 #define MAX_PUSHED     16      /* max # args we can push onto the stack */
 #define MAX_ENTRY      2048    /* maximum chars in a translated capability */
@@ -115,7 +115,7 @@ static char *init_string(void)
 /* initialize 'my_string', 'my_length' */
 {
        if (my_string == 0)
-               my_string = malloc(my_length = 256);
+               my_string = typeMalloc(char, my_length = 256);
        if (my_string == 0)
            _nc_err_abort("Out of memory");
 
@@ -128,7 +128,9 @@ static char *save_string(char *d, const char *const s)
        size_t have = (d - my_string);
        size_t need = have + strlen(s) + 2;
        if (need > my_length) {
-               my_string = realloc(my_string, my_length = (need + need));
+               my_string = (char *)realloc(my_string, my_length = (need + need));
+               if (my_string == 0)
+                   _nc_err_abort("Out of memory");
                d = my_string + have;
        }
        (void) strcpy(d, s);
@@ -154,11 +156,12 @@ static void push(void)
 static void pop(void)
 /* pop the top of the stack into onstack */
 {
-    if (stackptr == 0)
+    if (stackptr == 0) {
        if (onstack == 0)
            _nc_warning("I'm confused");
        else
            onstack = 0;
+    }
     else
        onstack = stack[--stackptr];
     param++;
@@ -374,13 +377,14 @@ int const parametrized)           /* do % translations if 1, pad translations if >=0 */
                        *dp++ = '%'; *dp++ = '/';
                        break;
                    case '=':
-                       if (seenr)
+                       if (seenr) {
                            if (param == 1)
                                onstack = 2;
                            else if (param == 2)
                                onstack = 1;
                            else
                                onstack = param;
+                       }
                        else
                            onstack = param;
                        break;
@@ -423,7 +427,7 @@ int const parametrized)             /* do % translations if 1, pad translations if >=0 */
                pop();
                break;
            case '0':   /* not clear any of the historical termcaps did this */
-               if (*s == '3')
+               if (*s == '3')
                    goto see03;
                else if (*s != '2')
                    goto invalid;
@@ -582,7 +586,7 @@ int const parametrized)             /* do % translations if 1, pad translations if >=0 */
     for (; *str && str != trimmed; str++)
     {
        int     c1, c2;
-       char    *cp;
+       char    *cp = 0;
 
        if (str[0] == '\\' && (str[1] == '^' || str[1] == ','))
        {
@@ -600,9 +604,7 @@ int const parametrized)             /* do % translations if 1, pad translations if >=0 */
        else if (sscanf(str, "%%?%%{%d}%%>%%t%%{%d}%%+%%;", &c1,&c2) == 2)
        {
            str = strchr(str, ';');
-           (void) sprintf(temp, "%%>");
-           (void) strcat(temp, unctrl(c1));
-           (void) strcat(temp, unctrl(c2));
+           (void) sprintf(temp, "%%>%s%s", unctrl(c1), unctrl(c2));
            bufptr = save_string(bufptr, temp);
        }
        else if (sscanf(str, "%%?%%{%d}%%>%%t%%'%c'%%+%%;", &c1,&ch2) == 2)