]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/write_entry.c
ncurses 5.7 - patch 20100130
[ncurses.git] / ncurses / tinfo / write_entry.c
index 057b3c22a44782dd2593bcad485da579a57c4667..5fca334d5ce5450d2c9d5031d18c46ac3cdc4f9a 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2009,2010 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            *
@@ -42,7 +42,6 @@
 #include <sys/stat.h>
 
 #include <tic.h>
-#include <term_entry.h>
 
 #ifndef S_ISDIR
 #define S_ISDIR(mode) ((mode & S_IFMT) == S_IFDIR)
@@ -54,7 +53,7 @@
 #define TRACE_OUT(p)           /*nothing */
 #endif
 
-MODULE_ID("$Id: write_entry.c,v 1.74 2009/09/19 20:30:48 Daniel.Jacobowitz Exp $")
+MODULE_ID("$Id: write_entry.c,v 1.76 2010/01/23 17:57:43 tom Exp $")
 
 static int total_written;
 
@@ -137,10 +136,12 @@ make_db_path(char *dst, const char *src, unsigned limit)
        if (_nc_is_dir_path(dst)) {
            rc = -1;
        } else {
+           static const char suffix[] = DBM_SUFFIX;
            unsigned have = strlen(dst);
-           if (have > 3 && strcmp(dst + have - 3, DBM_SUFFIX)) {
-               if (have + 3 <= limit)
-                   strcat(dst, DBM_SUFFIX);
+           unsigned need = strlen(suffix);
+           if (have > need && strcmp(dst + have - need, suffix)) {
+               if (have + need <= limit)
+                   strcat(dst, suffix);
                else
                    rc = -1;
            }
@@ -362,7 +363,7 @@ _nc_write_entry(TERMTYPE *const tp)
        start_time = 0;
     }
 
-    if (strlen(first_name) >= sizeof(filename) - 3)
+    if (strlen(first_name) >= sizeof(filename) - (2 + LEAF_LEN))
        _nc_warning("terminal name too long.");
 
     sprintf(filename, LEAF_FMT "/%s", first_name[0], first_name);
@@ -396,7 +397,7 @@ _nc_write_entry(TERMTYPE *const tp)
        if (*other_names != '\0')
            *(other_names++) = '\0';
 
-       if (strlen(ptr) > sizeof(linkname) - 3) {
+       if (strlen(ptr) > sizeof(linkname) - (2 + LEAF_LEN)) {
            _nc_warning("terminal alias %s too long.", ptr);
            continue;
        }