]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/write_entry.c
ncurses 6.0 - patch 20170311
[ncurses.git] / ncurses / tinfo / write_entry.c
index a5f8604ec88a7fac47c49e5fdfe714e65948954a..8a49a2c0d7f4b005f740f0a03b456a72ddd7631d 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2014,2015 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2015,2017 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            *
 #define TRACE_OUT(p)           /*nothing */
 #endif
 
-MODULE_ID("$Id: write_entry.c,v 1.93 2015/09/05 21:24:29 tom Exp $")
+MODULE_ID("$Id: write_entry.c,v 1.98 2017/02/05 01:47:34 tom Exp $")
 
 static int total_written;
+static int total_parts;
+static int total_size;
 
 static int make_db_root(const char *);
 
@@ -342,6 +344,8 @@ _nc_write_entry(TERMTYPE *const tp)
                       sizeof(buffer) - 1);
            data.size = name_size + 1;
 
+           total_size += data.size;
+           total_parts++;
            _nc_db_put(capdb, &key, &data);
 
            while (*other_names != '\0') {
@@ -356,6 +360,8 @@ _nc_write_entry(TERMTYPE *const tp)
                key.data = ptr;
                key.size = strlen(ptr);
 
+               total_size += data.size;
+               total_parts++;
                _nc_db_put(capdb, &key, &data);
            }
        }
@@ -438,13 +444,14 @@ _nc_write_entry(TERMTYPE *const tp)
        {
            int code;
 #if USE_SYMLINKS
-           if (first_name[0] == linkname[0])
-               strncpy(symlinkname, first_name, sizeof(symlinkname) - 1);
-           else {
-               _nc_STRCPY(symlinkname, "../", sizeof(suymlinkname));
-               strncat(symlinkname, filename, sizeof(symlinkname) - 4);
+#define MY_SIZE sizeof(symlinkname) - 1
+           if (first_name[0] == linkname[0]) {
+               _nc_STRNCPY(symlinkname, first_name, MY_SIZE);
+           } else {
+               _nc_STRCPY(symlinkname, "../", sizeof(symlinkname));
+               _nc_STRNCPY(symlinkname + 3, filename, MY_SIZE - 3);
            }
-           symlinkname[sizeof(symlinkname) - 1] = '\0';
+           symlinkname[MY_SIZE] = '\0';
 #endif /* USE_SYMLINKS */
 #if HAVE_REMOVE
            code = remove(linkname);
@@ -801,6 +808,8 @@ _nc_write_object(TERMTYPE *tp, char *buffer, unsigned *offset, unsigned limit)
 #endif /* NCURSES_XNAMES */
 
     total_written++;
+    total_parts++;
+    total_size = total_size + (int) (*offset + 1);
     return (OK);
 }
 
@@ -810,5 +819,7 @@ _nc_write_object(TERMTYPE *tp, char *buffer, unsigned *offset, unsigned limit)
 NCURSES_EXPORT(int)
 _nc_tic_written(void)
 {
+    TR(TRACE_DATABASE, ("_nc_tic_written %d entries, %d parts, %d size",
+                       total_written, total_parts, total_size));
     return total_written;
 }