]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/parse_entry.c
ncurses 5.9 - patch 20110807
[ncurses.git] / ncurses / tinfo / parse_entry.c
index 6e59775b7bd70831fc54271e8d89670402127057..0e3a8bfad198a7f97dc3a17f63fa796d12ab4c9e 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -46,9 +46,8 @@
 
 #include <ctype.h>
 #include <tic.h>
 
 #include <ctype.h>
 #include <tic.h>
-#include <term_entry.h>
 
 
-MODULE_ID("$Id: parse_entry.c,v 1.71 2009/07/11 18:14:21 tom Exp $")
+MODULE_ID("$Id: parse_entry.c,v 1.76 2011/07/27 01:14:47 tom Exp $")
 
 #ifdef LINT
 static short const parametrized[] =
 
 #ifdef LINT
 static short const parametrized[] =
@@ -204,6 +203,8 @@ _nc_extend_names(ENTRY * entryp, char *name, int token_type)
        { bad_tc_usage = TRUE; \
         _nc_warning("Legacy termcap allows only a trailing tc= clause"); }
 
        { bad_tc_usage = TRUE; \
         _nc_warning("Legacy termcap allows only a trailing tc= clause"); }
 
+#define MAX_NUMBER 0x7fff      /* positive shorts only */
+
 NCURSES_EXPORT(int)
 _nc_parse_entry(struct entry *entryp, int literal, bool silent)
 {
 NCURSES_EXPORT(int)
 _nc_parse_entry(struct entry *entryp, int literal, bool silent)
 {
@@ -445,8 +446,12 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
                break;
 
            case NUMBER:
                break;
 
            case NUMBER:
-               entryp->tterm.Numbers[entry_ptr->nte_index] =
-                   (short) _nc_curr_token.tk_valnumber;
+               if (_nc_curr_token.tk_valnumber > MAX_NUMBER) {
+                   entryp->tterm.Numbers[entry_ptr->nte_index] = MAX_NUMBER;
+               } else {
+                   entryp->tterm.Numbers[entry_ptr->nte_index] =
+                       (short) _nc_curr_token.tk_valnumber;
+               }
                break;
 
            case STRING:
                break;
 
            case STRING:
@@ -512,9 +517,9 @@ NCURSES_EXPORT(int)
 _nc_capcmp(const char *s, const char *t)
 /* compare two string capabilities, stripping out padding */
 {
 _nc_capcmp(const char *s, const char *t)
 /* compare two string capabilities, stripping out padding */
 {
-    if (!s && !t)
+    if (!VALID_STRING(s) && !VALID_STRING(t))
        return (0);
        return (0);
-    else if (!s || !t)
+    else if (!VALID_STRING(s) || !VALID_STRING(t))
        return (1);
 
     for (;;) {
        return (1);
 
     for (;;) {
@@ -669,7 +674,7 @@ postprocess_termcap(TERMTYPE *tp, bool has_base)
            else if (PRESENT(backspace_if_not_bs))
                cursor_left = backspace_if_not_bs;
        }
            else if (PRESENT(backspace_if_not_bs))
                cursor_left = backspace_if_not_bs;
        }
-       /* vi doesn't use "do", but it does seems to use nl (or '\n') instead */
+       /* vi doesn't use "do", but it does seem to use nl (or '\n') instead */
        if (WANTED(cursor_down)) {
            if (PRESENT(linefeed_if_not_lf))
                cursor_down = linefeed_if_not_lf;
        if (WANTED(cursor_down)) {
            if (PRESENT(linefeed_if_not_lf))
                cursor_down = linefeed_if_not_lf;
@@ -774,7 +779,7 @@ postprocess_termcap(TERMTYPE *tp, bool has_base)
      * isn't from mytinfo...
      */
     if (PRESENT(other_non_function_keys)) {
      * isn't from mytinfo...
      */
     if (PRESENT(other_non_function_keys)) {
-       char *base = other_non_function_keys;
+       char *base;
        char *bp, *cp, *dp;
        struct name_table_entry const *from_ptr;
        struct name_table_entry const *to_ptr;
        char *bp, *cp, *dp;
        struct name_table_entry const *from_ptr;
        struct name_table_entry const *to_ptr;
@@ -842,7 +847,7 @@ postprocess_termcap(TERMTYPE *tp, bool has_base)
                } else
                    *dp++ = *bp;
            }
                } else
                    *dp++ = *bp;
            }
-           *dp++ = '\0';
+           *dp = '\0';
 
            tp->Strings[to_ptr->nte_index] = _nc_save_str(buf2);
        }
 
            tp->Strings[to_ptr->nte_index] = _nc_save_str(buf2);
        }