From 7c3c3cbb3b6caab5d1102836fad2542baec69b7a Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 14 Sep 2017 21:57:12 +0200 Subject: [PATCH] tweaks: discard some obsolete debugging stuff --- src/color.c | 13 +------------ src/cut.c | 3 --- src/files.c | 26 ++------------------------ src/nano.c | 4 ---- src/prompt.c | 8 -------- src/rcfile.c | 19 +------------------ src/text.c | 4 ---- src/utils.c | 9 ++------- src/winio.c | 5 ----- 9 files changed, 6 insertions(+), 85 deletions(-) diff --git a/src/color.c b/src/color.c index e61e89ae..b1588848 100644 --- a/src/color.c +++ b/src/color.c @@ -125,9 +125,6 @@ void color_init(void) background = COLOR_BLACK; init_pair(ink->pairnum, foreground, background); -#ifdef DEBUG - fprintf(stderr, "init_pair(): fg = %hd, bg = %hd\n", foreground, background); -#endif } have_palette = TRUE; @@ -211,9 +208,6 @@ void color_update(void) /* If the filename didn't match anything, try the first line. */ if (sint == NULL) { -#ifdef DEBUG - fprintf(stderr, "No result from file extension, trying headerline...\n"); -#endif for (sint = syntaxes; sint != NULL; sint = sint->next) { if (found_in_list(sint->headers, openfile->fileage->data)) break; @@ -226,9 +220,7 @@ void color_update(void) struct stat fileinfo; magic_t cookie = NULL; const char *magicstring = NULL; -#ifdef DEBUG - fprintf(stderr, "No result from headerline either, trying libmagic...\n"); -#endif + if (stat(openfile->filename, &fileinfo) == 0) { /* Open the magic database and get a diagnosis of the file. */ cookie = magic_open(MAGIC_SYMLINK | @@ -243,9 +235,6 @@ void color_update(void) if (magicstring == NULL) statusline(ALERT, _("magic_file(%s) failed: %s"), openfile->filename, magic_error(cookie)); -#ifdef DEBUG - fprintf(stderr, "Returned magic string is: %s\n", magicstring); -#endif } } diff --git a/src/cut.c b/src/cut.c index ec514b3b..8521ad3a 100644 --- a/src/cut.c +++ b/src/cut.c @@ -129,9 +129,6 @@ void do_cut_text(bool copy_text, bool cut_till_eof) if (!keep_cutbuffer) { free_filestruct(cutbuffer); cutbuffer = NULL; -#ifdef DEBUG - fprintf(stderr, "Blew away cutbuffer =)\n"); -#endif /* Indicate that future cuts should add to the cutbuffer. */ keep_cutbuffer = TRUE; } diff --git a/src/files.c b/src/files.c index d2126245..e70bbfe9 100644 --- a/src/files.c +++ b/src/files.c @@ -264,10 +264,6 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi goto free_the_data; } -#ifdef DEBUG - fprintf(stderr, "In write_lockfile(), write successful (wrote %lu bytes)\n", (unsigned long)wroteamt); -#endif - if (fclose(filestream) == EOF) { statusline(MILD, _("Error writing lock file %s: %s"), lockfilename, strerror(errno)); @@ -314,10 +310,7 @@ int do_lockfile(const char *filename) snprintf(lockfilename, locknamesize, "%s/%s%s%s", dirname(namecopy), locking_prefix, basename(secondcopy), locking_suffix); - free(secondcopy); -#ifdef DEBUG - fprintf(stderr, "lock file name is %s\n", lockfilename); -#endif + if (stat(lockfilename, &fileinfo) != -1) { size_t readtot = 0; size_t readamt = 0; @@ -354,11 +347,6 @@ int do_lockfile(const char *filename) pidstring = charalloc(11); sprintf (pidstring, "%u", (unsigned int)lockpid); -#ifdef DEBUG - fprintf(stderr, "lockpid = %d\n", lockpid); - fprintf(stderr, "program name which created this lock file should be %s\n", lockprog); - fprintf(stderr, "user which created this lock file should be %s\n", lockuser); -#endif /* TRANSLATORS: The second %s is the name of the user, the third that of the editor. */ question = _("File %s is being edited (by %s with %s, PID %s); continue?"); room = COLS - strlenpt(question) + 7 - strlenpt(lockuser) - @@ -395,6 +383,7 @@ int do_lockfile(const char *filename) free_the_name: free(namecopy); + free(secondcopy); if (retval < 1) free(lockfilename); @@ -610,10 +599,6 @@ void switch_to_adjacent_buffer(bool to_next) /* Switch to the next or previous file buffer. */ openfile = to_next ? openfile->next : openfile->prev; -#ifdef DEBUG - fprintf(stderr, "filename is %s\n", openfile->filename); -#endif - #ifndef NANO_TINY /* When not in softwrap mode, make sure firstcolumn is zero. It might * be nonzero if we had softwrap mode on while in this buffer, and then @@ -2151,10 +2136,6 @@ int do_writeout(bool exiting) continue; } -#ifdef DEBUG - fprintf(stderr, "filename is %s\n", answer); -#endif - #ifndef DISABLE_EXTRA /* If the current file has been modified, we've pressed * Ctrl-X at the edit window to exit, we've pressed "y" at @@ -2494,9 +2475,6 @@ char **cwd_tab_completion(const char *buf, bool allow_files, size_t while ((nextdir = readdir(dir)) != NULL) { bool skip_match = FALSE; -#ifdef DEBUG - fprintf(stderr, "Comparing \'%s\'\n", nextdir->d_name); -#endif /* See if this matches. */ if (strncmp(nextdir->d_name, filename, filenamelen) == 0 && (*filename == '.' || (strcmp(nextdir->d_name, ".") != 0 && diff --git a/src/nano.c b/src/nano.c index f69d2aeb..fec3a9a8 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1769,10 +1769,6 @@ int do_mouse(void) #endif leftedge = get_page_start(xplustabs()); -#ifdef DEBUG - fprintf(stderr, "mouse_row = %d, current_y = %ld\n", mouse_row, (long)openfile->current_y); -#endif - /* Move current up or down to the row corresponding to mouse_row. */ if (row_count < 0) go_back_chunks(-row_count, &openfile->current, &leftedge); diff --git a/src/prompt.c b/src/prompt.c index ac9a6654..30e21c38 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -470,10 +470,6 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs, if (statusbar_x > strlen(answer)) statusbar_x = strlen(answer); -#ifdef DEBUG - fprintf(stderr, "acquiring: answer = \"%s\", statusbar_x = %lu\n", answer, (unsigned long) statusbar_x); -#endif - update_the_statusbar(); while (TRUE) { @@ -668,10 +664,6 @@ int do_prompt(bool allow_tabs, bool allow_files, blank_statusbar(); wnoutrefresh(bottomwin); -#ifdef DEBUG - fprintf(stderr, "answer = \"%s\"\n", answer); -#endif - #ifdef ENABLE_TABCOMP /* If we've done tab completion, there might still be a list of * filename matches on the edit window. Clear them off. */ diff --git a/src/rcfile.c b/src/rcfile.c index 3750bf3e..2988d4fc 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -448,14 +448,6 @@ void parse_binding(char *ptr, bool dobind) goto free_things; } -#ifdef DEBUG - if (dobind) - fprintf(stderr, "newsc address is now %ld, assigned func = %ld, menu = %x\n", - (long)&newsc, (long)newsc->scfunc, menu); - else - fprintf(stderr, "unbinding \"%s\" from menu %x\n", keycopy, menu); -#endif - if (dobind) { subnfunc *f; int mask = 0; @@ -490,20 +482,12 @@ void parse_binding(char *ptr, bool dobind) rcfile_error(N_("Sorry, keystroke \"%s\" may not be rebound"), newsc->keystr); goto free_things; } -#ifdef DEBUG - fprintf(stderr, "s->keystr = \"%s\"\n", newsc->keystr); - fprintf(stderr, "s->keycode = \"%d\"\n", newsc->keycode); -#endif } /* Now find and delete any existing same shortcut in the menu(s). */ for (s = sclist; s != NULL; s = s->next) { - if ((s->menus & menu) && !strcmp(s->keystr, keycopy)) { -#ifdef DEBUG - fprintf(stderr, "deleting entry from among menus %x\n", s->menus); -#endif + if ((s->menus & menu) && !strcmp(s->keystr, keycopy)) s->menus &= ~menu; - } } if (dobind) { @@ -1225,7 +1209,6 @@ void parse_one_nanorc(void) #ifdef DEBUG fprintf(stderr, "Going to parse file \"%s\"\n", nanorc); #endif - rcstream = fopen(nanorc, "rb"); /* If opening the file succeeded, parse it. Otherwise, only diff --git a/src/text.c b/src/text.c index 343c0ad2..1cc867d4 100644 --- a/src/text.c +++ b/src/text.c @@ -1350,10 +1350,6 @@ void add_undo(undo_type action) break; } -#ifdef DEBUG - fprintf(stderr, " >> openfile->current->data = \"%s\", current_x = %lu, u->begin = %lu, type = %d\n", - openfile->current->data, (unsigned long)openfile->current_x, (unsigned long)u->begin, action); -#endif openfile->last_action = action; } diff --git a/src/utils.c b/src/utils.c index 9cb53a41..352f6bec 100644 --- a/src/utils.c +++ b/src/utils.c @@ -179,10 +179,6 @@ const char *fixbounds(const char *r) char *r2 = charalloc(strlen(r) * 5); char *r3; -#ifdef DEBUG - fprintf(stderr, "fixbounds(): Start string = \"%s\"\n", r); -#endif - for (i = 0; i < strlen(r); i++) { if (r[i] != '\0' && r[i] == '\\' && (r[i + 1] == '>' || r[i + 1] == '<')) { strcpy(&r2[j], "[[:"); @@ -194,12 +190,11 @@ const char *fixbounds(const char *r) r2[j] = r[i]; j++; } + r2[j] = '\0'; r3 = mallocstrcpy(NULL, r2); free(r2); -#ifdef DEBUG - fprintf(stderr, "fixbounds(): Ending string = \"%s\"\n", r3); -#endif + return (const char *) r3; #endif /* !GNU_WORDBOUNDS */ diff --git a/src/winio.c b/src/winio.c index 26d77c2d..47ccb21f 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1440,11 +1440,6 @@ long get_unicode_kbinput(WINDOW *win, int kbinput) statusline(HUSH, _("Unicode Input: %s"), partial); } -#ifdef DEBUG - fprintf(stderr, "get_unicode_kbinput(): kbinput = %d, uni_digits = %d, uni = %ld, retval = %ld\n", - kbinput, uni_digits, uni, retval); -#endif - /* If we have an end result, reset the Unicode digit counter. */ if (retval != ERR) uni_digits = 0;