diff options
-rw-r--r-- | fgetc.c | 22 | ||||
-rw-r--r-- | index.c | 58 | ||||
-rw-r--r-- | list.c | 74 | ||||
-rw-r--r-- | smenu.c | 2268 | ||||
-rw-r--r-- | usage.c | 12 | ||||
-rw-r--r-- | utf8.c | 121 | ||||
-rw-r--r-- | utils.c | 82 | ||||
-rw-r--r-- | xmalloc.c | 42 |
8 files changed, 1350 insertions, 1329 deletions
@@ -1,11 +1,11 @@ /* ########################################################### */ /* This Software is licensed under the GPL licensed Version 2, */ -/* please read http://www.gnu.org/copyleft/gpl.html */ +/* please read http://www.gnu.org/copyleft/gpl.html. */ /* ########################################################### */ -/* ************************************************************************ */ -/* Custom fgetc/ungetc implementation able to unget more than one character */ -/* ************************************************************************ */ +/* ************************************************************************* */ +/* Custom fgetc/ungetc implementation able to unget more than one character. */ +/* ************************************************************************* */ #include <stdio.h> #include "fgetc.h" @@ -17,20 +17,20 @@ enum static char getc_buffer[GETC_BUFF_SIZE] = { '\0' }; -static long next_buffer_pos = 0; /* next free position in the getc buffer */ +static long next_buffer_pos = 0; /* Next free position in the getc buffer. */ -/* ======================================= */ -/* Gets a (possibly pushed-back) character */ -/* ======================================= */ +/* ======================================== */ +/* Gets a (possibly pushed-back) character. */ +/* ======================================== */ int my_fgetc(FILE * input) { return (next_buffer_pos > 0) ? getc_buffer[--next_buffer_pos] : fgetc(input); } -/* ============================== */ -/* Pushes character back on input */ -/* ============================== */ +/* =============================== */ +/* Pushes character back on input. */ +/* =============================== */ void my_ungetc(int c) { @@ -1,11 +1,11 @@ /* ########################################################### */ /* This Software is licensed under the GPL licensed Version 2, */ -/* please read http://www.gnu.org/copyleft/gpl.html */ +/* please read http://www.gnu.org/copyleft/gpl.html. */ /* ########################################################### */ -/* Ternary Search Tree and sorted array creation functions */ -/* Inspired by: https://www.cs.princeton.edu/~rs/strings/tstdemo.c */ -/* *************************************************************** */ +/* Ternary Search Tree and sorted array creation functions */ +/* Inspired by: https://www.cs.princeton.edu/~rs/strings/tstdemo.c. */ +/* **************************************************************** */ #include <stdlib.h> #include <stdint.h> @@ -18,13 +18,13 @@ #include "utils.h" #include "index.h" -/* List of words matching the current search */ -/* """"""""""""""""""""""""""""""""""""""""" */ -ll_t * tst_search_list; /* Must be initialized by ll_new() before use */ +/* List of words matching the current search. */ +/* """""""""""""""""""""""""""""""""""""""""" */ +ll_t * tst_search_list; /* Must be initialized by ll_new() before use. */ -/* ====================================== */ -/* Ternary search tree insertion function */ -/* ====================================== */ +/* ======================================= */ +/* Ternary search tree insertion function. */ +/* ======================================= */ tst_node_t * tst_insert(tst_node_t * p, wchar_t * w, void * data) { @@ -54,10 +54,10 @@ tst_insert(tst_node_t * p, wchar_t * w, void * data) return (p); } -/* ===================================== */ -/* Ternary search tree deletion function */ -/* user data area not cleaned */ -/* ===================================== */ +/* ====================================== */ +/* Ternary search tree deletion function. */ +/* User data area not cleaned. */ +/* ====================================== */ void tst_cleanup(tst_node_t * p) { @@ -73,11 +73,11 @@ tst_cleanup(tst_node_t * p) /* ========================================================== */ /* Recursive traversal of a ternary tree. A callback function */ -/* is also called when a complete string is found */ -/* returns 1 if the callback function succeed (returned 1) at */ -/* least once */ -/* the first_call argument is for initializing the static */ -/* variable */ +/* is also called when a complete string is found. */ +/* Returns 1 if the callback function succeed (returned 1) at */ +/* least once. */ +/* The first_call argument is for initializing the static */ +/* variable. */ /* ========================================================== */ int tst_traverse(tst_node_t * p, int (*callback)(void *), int first_call) @@ -190,9 +190,9 @@ tst_fuzzy_traverse(tst_node_t * p, int (*callback)(void *), int first_call, return !!rc; } -/* ====================================================================== */ -/* Searches a complete string in a ternary tree starting from a root node */ -/* ====================================================================== */ +/* ======================================================================= */ +/* Searches a complete string in a ternary tree starting from a root node. */ +/* ======================================================================= */ void * tst_search(tst_node_t * root, wchar_t * w) { @@ -220,7 +220,7 @@ tst_search(tst_node_t * root, wchar_t * w) /* ================================================================= */ /* Searches all strings beginning with the same prefix. */ /* the callback function will be applied to each of theses strings */ -/* returns NULL if no string matched the prefix */ +/* returns NULL if no string matched the prefix. */ /* ================================================================= */ void * tst_prefix_search(tst_node_t * root, wchar_t * w, int (*callback)(void *)) @@ -264,13 +264,13 @@ insert_sorted_index(long ** array, long * size, long * nb, long value) if (*nb > 0) { - /* bisection search */ - /* """""""""""""""" */ + /* Bisection search. */ + /* """"""""""""""""" */ while (left < right) { middle = (left + right) / 2; if ((*array)[middle] == value) - return; /* Value already in array */ + return; /* Value already in array. */ if (value < (*array)[middle]) right = middle; @@ -307,13 +307,13 @@ insert_sorted_ptr(tst_node_t *** array, unsigned long long * size, if (*nb > 0) { - /* bisection search */ - /* """""""""""""""" */ + /* Bisection search. */ + /* """"""""""""""""" */ while (left < right) { middle = (left + right) / 2; if ((intptr_t)((*array)[middle]) == (intptr_t)ptr) - return; /* Value already in array */ + return; /* Value already in array. */ if ((intptr_t)ptr < (intptr_t)((*array)[middle])) right = middle; @@ -10,7 +10,7 @@ /* will not try to allocate or free this data pointer. */ /* */ /* Also accessors are not provided, the user has to directly manipulate */ -/* the structure members (head, tail, len, data, prev, next) */ +/* the structure members (head, tail, len, data, prev, next). */ /* ********************************************************************* */ #include <stdio.h> @@ -26,9 +26,9 @@ static ll_node_t * ll_partition(ll_node_t * l, ll_node_t * h, int (*comp)(void *, void *), void (*swap)(void *, void *)); -/* ========================= */ -/* Creates a new linked list */ -/* ========================= */ +/* ========================== */ +/* Creates a new linked list. */ +/* ========================== */ ll_t * ll_new(void) { @@ -38,9 +38,9 @@ ll_new(void) return ret; } -/* ========================= */ -/* Initializes a linked list */ -/* ========================= */ +/* ========================== */ +/* Initializes a linked list. */ +/* ========================== */ void ll_init(ll_t * list) { @@ -49,9 +49,9 @@ ll_init(ll_t * list) list->len = 0; } -/* ===================================================== */ -/* Allocates the space for a new node in the linked list */ -/* ===================================================== */ +/* ====================================================== */ +/* Allocates the space for a new node in the linked list. */ +/* ====================================================== */ ll_node_t * ll_new_node(void) { @@ -60,12 +60,12 @@ ll_new_node(void) return ret; } -/* ===================================================================== */ -/* Appends a new node filled with its data at the end of the linked list */ -/* The user is responsible for the memory management of the data. */ -/* */ -/* Note: list is assumed to be initialized by ll_new(). */ -/* ===================================================================== */ +/* ====================================================================== */ +/* Appends a new node filled with its data at the end of the linked list. */ +/* The user is responsible for the memory management of the data. */ +/* */ +/* Note: list is assumed to be initialized by ll_new(). */ +/* ====================================================================== */ void ll_append(ll_t * const list, void * const data) { @@ -121,9 +121,9 @@ ll_prepend(ll_t * const list, void * const data) #endif #if 0 -/* ======================================================== */ -/* Inserts a new node before the specified node in the list */ -/* ======================================================== */ +/* ========================================================= */ +/* Inserts a new node before the specified node in the list. */ +/* ========================================================= */ void ll_insert_before(ll_t * const list, ll_node_t * node, void * const data) { @@ -149,9 +149,9 @@ ll_insert_before(ll_t * const list, ll_node_t * node, void * const data) #endif #if 0 -/* ======================================================= */ -/* Inserts a new node after the specified node in the list */ -/* ======================================================= */ +/* ======================================================== */ +/* Inserts a new node after the specified node in the list. */ +/* ======================================================== */ void ll_insert_after(ll_t * const list, ll_node_t * node, void * const data) { @@ -177,7 +177,7 @@ ll_insert_after(ll_t * const list, ll_node_t * node, void * const data) #endif /* ====================================================== */ -/* Partition code for the quicksort function */ +/* Partition code for the quicksort function. */ /* Based on code found here: */ /* http://www.geeksforgeeks.org/quicksort-for-linked-list */ /* ====================================================== */ @@ -187,11 +187,11 @@ ll_partition(ll_node_t * l, ll_node_t * h, int (*comp)(void *, void *), { /* Considers last element as pivot, places the pivot element at its */ /* correct position in sorted array, and places all smaller (smaller than */ - /* pivot) to left of pivot and all greater elements to right of pivot */ + /* pivot) to left of pivot and all greater elements to right of pivot. */ /* """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */ - /* Set pivot as h element */ - /* """""""""""""""""""""" */ + /* Set pivot as h element. */ + /* """"""""""""""""""""""" */ void * x = h->data; ll_node_t * i = l->prev; @@ -213,9 +213,9 @@ ll_partition(ll_node_t * l, ll_node_t * h, int (*comp)(void *, void *), return i; } -/* ======================================================= */ -/* A recursive implementation of quicksort for linked list */ -/* ======================================================= */ +/* ======================================================== */ +/* A recursive implementation of quicksort for linked list. */ +/* ======================================================== */ void ll_quicksort(ll_node_t * l, ll_node_t * h, int (*comp)(void *, void *), void (*swap)(void * a, void *)) @@ -228,21 +228,21 @@ ll_quicksort(ll_node_t * l, ll_node_t * h, int (*comp)(void *, void *), } } -/* =========================== */ -/* A linked list sort function */ -/* =========================== */ +/* ============================ */ +/* A linked list sort function. */ +/* ============================ */ void ll_sort(ll_t * list, int (*comp)(void *, void *), void (*swap)(void * a, void *)) { - /* Call the recursive ll_quicksort function */ - /* """""""""""""""""""""""""""""""""""""""" */ + /* Call the recursive ll_quicksort function. */ + /* """"""""""""""""""""""""""""""""""""""""" */ ll_quicksort(list->head, list->tail, comp, swap); } -/* ================================= */ -/* Removes a node from a linked list */ -/* ================================= */ +/* ================================== */ +/* Removes a node from a linked list. */ +/* ================================== */ int ll_delete(ll_t * const list, ll_node_t * node) { @@ -48,38 +48,38 @@ #include "usage.h" #include "smenu.h" -/* **************** */ -/* Extern variables */ -/* **************** */ +/* ***************** */ +/* Extern variables. */ +/* ***************** */ extern ll_t * tst_search_list; -/* **************** */ -/* Global variables */ -/* **************** */ +/* ***************** */ +/* Global variables. */ +/* ***************** */ -word_t * word_a; /* array containing words data (size: count) */ -long count = 0; /* number of words read from stdin */ -long current; /* index the current selection under the cursor) */ -long new_current; /* final current position, (used in search function) */ -long prev_current; /* previous position stored when using direct access */ +word_t * word_a; /* array containing words data (size: count). */ +long count = 0; /* number of words read from stdin. */ +long current; /* index the current selection under the cursor). */ +long new_current; /* final cur. position, (used in search function). */ +long prev_current; /* prev. position stored when using direct access. */ long * line_nb_of_word_a; /* array containing the line number (from 0) * - * of each word read */ + * of each word read. */ long * first_word_in_line_a; /* array containing the index of the first * - * word of each lines */ + * word of each lines. */ search_mode_t search_mode = NONE; search_mode_t old_search_mode = NONE; -int help_mode = 0; /* 1 if help is displayed else 0 */ +int help_mode = 0; /* 1 if help is displayed else 0. */ char * word_buffer; int (*my_isprint)(int); -/* UTF-8 useful symbols */ -/* """""""""""""""""""" */ +/* UTF-8 useful symbols. */ +/* """"""""""""""""""""" */ char * left_arrow = "\xe2\x86\x90"; char * up_arrow = "\xe2\x86\x91"; char * right_arrow = "\xe2\x86\x92"; @@ -94,14 +94,14 @@ char * sbar_curs = "\xe2\x95\x91"; /* box_drawings_double_vertical */ char * sbar_arr_up = "\xe2\x96\xb2"; /* black_up_pointing_triangle */ char * sbar_arr_down = "\xe2\x96\xbc"; /* black_down_pointing_triangle */ -/* Variables used to manage the direct access entries */ -/* """""""""""""""""""""""""""""""""""""""""""""""""" */ +/* Variables used to manage the direct access entries. */ +/* """"""""""""""""""""""""""""""""""""""""""""""""""" */ daccess_t daccess; char * daccess_stack; int daccess_stack_head; -/* Variables used for fuzzy and substring searching */ -/* """""""""""""""""""""""""""""""""""""""""""""""" */ +/* Variables used for fuzzy and substring searching. */ +/* """"""""""""""""""""""""""""""""""""""""""""""""" */ long * matching_words_a; long matching_words_a_size; long matches_count; @@ -111,8 +111,8 @@ long best_matches_count; long * alt_matching_words_a = NULL; long alt_matches_count; -/* Variables used in signal handlers */ -/* """"""""""""""""""""""""""""""""" */ +/* Variables used in signal handlers. */ +/* """""""""""""""""""""""""""""""""" */ volatile sig_atomic_t got_winch = 0; volatile sig_atomic_t got_winch_alrm = 0; volatile sig_atomic_t got_help_alrm = 0; @@ -123,37 +123,37 @@ volatile sig_atomic_t got_sigsegv = 0; volatile sig_atomic_t got_sigterm = 0; volatile sig_atomic_t got_sighup = 0; -/* Variables used when a timeout is set (option -x) */ -/* """""""""""""""""""""""""""""""""""""""""""""""" */ +/* Variables used when a timeout is set (option -x). */ +/* """"""""""""""""""""""""""""""""""""""""""""""""" */ timeout_t timeout; char * timeout_word; /* printed word when the timeout type is WORD. */ char * timeout_seconds; /* string containing the number of remaining * * seconds. */ int quiet_timeout = 0; /* 1 when we want no message to be displayed. */ -/* ************** */ -/* Help functions */ -/* ************** */ +/* *************** */ +/* Help functions. */ +/* *************** */ -/* ==================== */ -/* Help message display */ -/* ==================== */ +/* ===================== */ +/* Help message display. */ +/* ===================== */ void help(win_t * win, term_t * term, long last_line, toggle_t * toggle) { - int index; /* used to identify the objects long the help line */ - int line = 0; /* number of windows lines used by the help line */ - int len = 0; /* length of the help line */ - int offset = 0; /* offset from the first column of the terminal to * - * the start of the help line */ - int entries_nb; /* number of help entries to display */ - int help_len; /* total length of the help line */ + int index; /* used to identify the objects long the help line. */ + int line = 0; /* number of windows lines used by the help line. */ + int len = 0; /* length of the help line. */ + int offset = 0; /* offset from the first column of the terminal to * + * the start of the help line. */ + int entries_nb; /* number of help entries to display. */ + int help_len; /* total length of the help line. */ struct entry_s { - char attr; /* r=reverse, n=normal, b=bold */ - char * str; /* string to be displayed for an object in the help line */ - int len; /* length of one of these objects */ + char attr; /* r=reverse, n=normal, b=bold. */ + char * str; /* string to be displayed for an object in the help line. */ + int len; /* length of one of these objects. */ }; char * arrows = concat(left_arrow, up_arrow, right_arrow, down_arrow, @@ -175,19 +175,19 @@ help(win_t * win, term_t * term, long last_line, toggle_t * toggle) entries_nb = sizeof(entries) / sizeof(struct entry_s); - /* Remove the last two entries if tagging is not enabled */ - /* """"""""""""""""""""""""""""""""""""""""""""""""""""" */ + /* Remove the last two entries if tagging is not enabled. */ + /* """""""""""""""""""""""""""""""""""""""""""""""""""""" */ if (!toggle->taggable) entries_nb -= 2; - /* Get the total length of the help line */ - /* """"""""""""""""""""""""""""""""""""" */ + /* Get the total length of the help line. */ + /* """""""""""""""""""""""""""""""""""""" */ help_len = 0; for (index = 0; index < entries_nb; index++) help_len += entries[index].len; /* Save the position of the terminal cursor so that it can be */ - /* put back there after printing of the help line */ + /* put back there after printing of the help line. */ /* """""""""""""""""""""""""""""""""""""""""""""""""""""""""" */ tputs(TPARM1(save_cursor), 1, outch); @@ -202,8 +202,8 @@ help(win_t * win, term_t * term, long last_line, toggle_t * toggle) fputc(' ', stdout); } - /* Print the different objects forming the help line */ - /* """"""""""""""""""""""""""""""""""""""""""""""""" */ + /* Print the different objects forming the help line. */ + /* """""""""""""""""""""""""""""""""""""""""""""""""" */ for (index = 0; index < entries_nb; index++) { if ((len += entries[index].len) >= term->ncolumns - 1) @@ -239,27 +239,27 @@ help(win_t * win, term_t * term, long last_line, toggle_t * toggle) tputs(TPARM1(exit_attribute_mode), 1, outch); tputs(TPARM1(clr_eol), 1, outch); - /* Relocate the cursor to its saved position */ - /* """"""""""""""""""""""""""""""""""""""""" */ + /* Relocate the cursor to its saved position. */ + /* """""""""""""""""""""""""""""""""""""""""" */ tputs(TPARM1(restore_cursor), 1, outch); } -/* ********************************** */ -/* Attributes string parsing function */ -/* ********************************** */ - -/* ================================ */ -/* Decode attributes toggles if any */ -/* b -> bold */ -/* d -> dim */ -/* r -> reverse */ -/* s -> standout */ -/* u -> underline */ -/* i -> italic */ -/* */ -/* Returns 0 if some unexpected */ -/* toggle is found else 0 */ -/* ================================ */ +/* *********************************** */ +/* Attributes string parsing function. */ +/* *********************************** */ + +/* ================================= */ +/* Decode attributes toggles if any. */ +/* b -> bold */ +/* d -> dim */ +/* r -> reverse */ +/* s -> standout */ +/* u -> underline */ +/* i -> italic */ +/* */ +/* Returns 0 if some unexpected. */ +/* toggle is found else 0. */ +/* ================================= */ int decode_attr_toggles(char * s, attr_t * attr) { @@ -310,8 +310,8 @@ decode_attr_toggles(char * s, attr_t * attr) /* where: */ /* fg and bg are short representing a color value */ /* toggles is an array of toggles (see decode_attr_toggles) */ -/* Returns 1 on success else 0 */ -/* attr will be filled by the function */ +/* Returns 1 on success else 0. */ +/* attr will be filled by the function. */ /* =========================================================*/ int parse_attr(char * str, attr_t * attr, short max_color) @@ -347,7 +347,7 @@ parse_attr(char * str, attr_t * attr, short max_color) return 0; } } - else /* no / in the first string */ + else /* no / in the first string. */ { d2 = -1; if (sscanf(s1, "%hd", &d1) == 0) @@ -378,9 +378,9 @@ parse_attr(char * str, attr_t * attr, short max_color) return rc; } -/* ============================================= */ -/* Set the terminal attributes according to attr */ -/* ============================================= */ +/* ============================================== */ +/* Set the terminal attributes according to attr. */ +/* ============================================== */ void apply_attr(term_t * term, attr_t attr) { @@ -409,9 +409,9 @@ apply_attr(term_t * term, attr_t attr) tputs(TPARM1(enter_italics_mode), 1, outch); } -/* ******************** */ -/* ini parsing function */ -/* ******************** */ +/* ********************* */ +/* ini parsing function. */ +/* ********************* */ /* ===================================================== */ /* Callback function called when parsing each non-header */ @@ -492,8 +492,8 @@ ini_cb(win_t * win, term_t * term, limits_t * limits, timers_t * timers, } \ } - /* [colors] section */ - /* """""""""""""""" */ + /* [colors] section. */ + /* """"""""""""""""" */ if (has_colors) { if (strcmp(name, "method") == 0) @@ -537,8 +537,8 @@ ini_cb(win_t * win, term_t * term, limits_t * limits, timers_t * timers, { int v; - /* [window] section */ - /* """""""""""""""" */ + /* [window] section. */ + /* """"""""""""""""" */ if (strcmp(name, "lines") == 0) { if ((error = !(sscanf(value, "%d", &v) == 1 && v >= 0))) @@ -551,8 +551,8 @@ ini_cb(win_t * win, term_t * term, limits_t * limits, timers_t * timers, { int v; - /* [limits] section */ - /* """""""""""""""" */ + /* [limits] section. */ + /* """"""""""""""""" */ if (strcmp(name, "word_length") == 0) { if ((error = !(sscanf(value, "%d", &v) == 1 && v > 0))) @@ -579,8 +579,8 @@ ini_cb(win_t * win, term_t * term, limits_t * limits, timers_t * timers, { int v; - /* [timers] section */ - /* """""""""""""""" */ + /* [timers] section. */ + /* """"""""""""""""" */ if (strcmp(name, "help") == 0) { if ((error = !(sscanf(value, "%d", &v) == 1 && v > 0))) @@ -612,8 +612,8 @@ ini_cb(win_t * win, term_t * term, limits_t * limits, timers_t * timers, } else if (strcmp(section, "misc") == 0) { - /* [misc] section */ - /* """""""""""""""" */ + /* [misc] section. */ + /* """"""""""""""" */ if (strcmp(name, "default_search_method") == 0) { if (misc->default_search_method == NONE) @@ -634,14 +634,14 @@ out: } /* ======================================================================== */ -/* Load an .ini format file */ +/* Load an .ini format file. */ /* filename - path to a file */ /* report - callback can return non-zero to stop, the callback error code */ /* returned from this function. */ -/* return - return 0 on success */ +/* return - return 0 on success. */ /* */ /* This function is public domain. No copyright is claimed. */ -/* Jon Mayo April 2011 */ +/* Jon Mayo April 2011. */ /* ======================================================================== */ int ini_load(const char * filename, win_t * win, term_t * term, limits_t * limits, @@ -658,21 +658,23 @@ ini_load(const char * filename, win_t * win, term_t * term, limits_t * limits, int cnt; int error; - /* If the filename is empty we skip this phase and use the default values */ - /* """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */ + /* If the filename is empty we skip this phase and use the */ + /* default values. */ + /* """"""""""""""""""""""""""""""""""""""""""""""""""""""" */ if (filename == NULL) return 1; - /* We do that if the file is not readable as well */ - /* """""""""""""""""""""""""""""""""""""""""""""" */ + /* We do that if the file is not readable as well. */ + /* """"""""""""""""""""""""""""""""""""""""""""""" */ f = fopen(filename, "r"); if (!f) - return 0; /* Returns success as the presence of this file is optional */ + return 0; /* Returns success as the presence of this file * + | is optional. */ error = 0; - /* Skip blank lines */ - /* """""""""""""""" */ + /* Skip blank lines. */ + /* """"""""""""""""" */ while (fscanf(f, "%*[\n]") == 1) { } @@ -681,8 +683,8 @@ ini_load(const char * filename, win_t * win, term_t * term, limits_t * limits, { if (fscanf(f, " [%127[^];\n]]", section) == 1) { - /* Do nothing */ - /* """""""""" */ + /* Do nothing. */ + /* """"""""""" */ } if ((cnt = fscanf(f, " %63[^=;\n] = %255[^;\n]", name, value))) { @@ -695,8 +697,8 @@ ini_load(const char * filename, win_t * win, term_t * term, limits_t * limits, for (s = value + strlen(value) - 1; s > value && isspace(*s); s--) *s = 0; - /* Callback function calling */ - /* """"""""""""""""""""""""" */ + /* Callback function calling. */ + /* """""""""""""""""""""""""" */ error = report(win, term, limits, timers, misc, langinfo, section, name, value); @@ -705,15 +707,15 @@ ini_load(const char * filename, win_t * win, term_t * term, limits_t * limits, } if (fscanf(f, " ;%*[^\n]")) { - /* To silence the compiler about unused results */ + /* To silence the compiler about unused results. */ } - /* Skip blank lines */ - /* """""""""""""""" */ + /* Skip blank lines. */ + /* """"""""""""""""" */ while (fscanf(f, "%*[\n]") == 1) { - /* Do nothing */ - /* """""""""" */ + /* Do nothing. */ + /* """"""""""" */ } } @@ -753,7 +755,7 @@ make_ini_path(char * name, char * base) len = strlen(home) + strlen(name) + 3; if (path_max < 0) - path_max = 4096; /* POSIX minimal value */ + path_max = 4096; /* POSIX minimal value. */ if (len <= path_max) { @@ -772,13 +774,13 @@ make_ini_path(char * name, char * base) return path; } -/* ******************************** */ -/* Functions used when sorting tags */ -/* ******************************** */ +/* ********************************* */ +/* Functions used when sorting tags. */ +/* ********************************* */ -/* =========================================================== */ -/* Compare the pin order of two pinned word in the output list */ -/* =========================================================== */ +/* ============================================================ */ +/* Compare the pin order of two pinned word in the output list. */ +/* ============================================================ */ int tag_comp(void * a, void * b) { @@ -791,9 +793,9 @@ tag_comp(void * a, void * b) return (oa->order < ob->order) ? -1 : 1; } -/* ======================================================== */ -/* Swap the values of two selected words in the output list */ -/* ======================================================== */ +/* ========================================================= */ +/* Swap the values of two selected words in the output list. */ +/* ========================================================= */ void tag_swap(void * a, void * b) { @@ -811,9 +813,9 @@ tag_swap(void * a, void * b) ob->order = tmp_order; } -/* ***************** */ -/* Utility functions */ -/* ***************** */ +/* ****************** */ +/* Utility functions. */ +/* ****************** */ /* =================================================================== */ /* Create a new element to be added to the tst_search_list used by the */ @@ -831,9 +833,9 @@ sub_tst_new(void) return elem; } -/* ======================================== */ -/* Emit a small (visual) beep warn the user */ -/* ======================================== */ +/* ========================================= */ +/* Emit a small (visual) beep warn the user. */ +/* ========================================= */ void my_beep(toggle_t * toggle) { @@ -862,9 +864,9 @@ my_beep(toggle_t * toggle) } } -/* ========================================== */ -/* Integer verification constraint for ctxopt */ -/* ========================================== */ +/* =========================================== */ +/* Integer verification constraint for ctxopt. */ +/* =========================================== */ int check_integer_constraint(int nb_args, char ** args, char * value, char * par) { @@ -888,33 +890,33 @@ update_bitmaps(search_mode_t mode, search_data_t * data, long i, j, n; /* work variables */ long lmg; /* position of the last matching glyph of the search buffer * - * in a word */ + * in a word. */ long sg; /* index going from lmg backward to 0 of the tested glyphs * - * of the search buffer (searched glyph) */ + * of the search buffer (searched glyph). */ - long bm_len; /* number of chars taken by the bitmask */ + long bm_len; /* number of chars taken by the bitmask. */ char * start; /* pointer on the position of the matching position * - * of the last search buffer glyph in the word */ + * of the last search buffer glyph in the word. */ - char * bm; /* the word's current bitmap */ + char * bm; /* the word's current bitmap. */ - char * str; /* copy of the current word put in lower case */ - char * str_orig; /* original version of the word */ + char * str; /* copy of the current word put in lower case. */ + char * str_orig; /* original version of the word. */ char * first_glyph; - char * sb_orig = data->buf; /* sb: search buffer */ + char * sb_orig = data->buf; /* sb: search buffer. */ char * sb; long * o = data->utf8_off_a; /* array of the offsets of the search * - * buffer glyphs */ + * buffer glyphs. */ long * l = data->utf8_len_a; /* array of the lengths in bytes of * - * the search buffer glyphs */ + * the search buffer glyphs. */ long last = data->utf8_len - 1; /* offset of the last glyph in the * - * search buffer */ + * search buffer. */ - long badness = 0; /* number of 0s between two 1s */ + long badness = 0; /* number of 0s between two 1s. */ best_matches_count = 0; @@ -937,17 +939,17 @@ update_bitmaps(search_mode_t mode, search_data_t * data, str_orig = xstrdup(word_a[n].str + daccess.flength); /* We need to remove the trailing spaces to use the */ - /* following algorithm */ - /* .len holds the original length in bytes of the word */ + /* following algorithm. */ + /* .len holds the original length in bytes of the word. */ /* """""""""""""""""""""""""""""""""""""""""""""""""""" */ rtrim(str_orig, " \t", 0); bm_len = (word_a[n].mb - daccess.flength) / CHAR_BIT + 1; bm = word_a[n].bitmap; - /* In fuzzy search mode str is converted in lowercases */ - /* for comparison reason. */ - /* """"""""""""""""""""""""""""""""""""""""""""""""""" */ + /* In fuzzy search mode str are converted in lower case letters */ + /* for comparison reason. */ + /* """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */ if (mode == FUZZY) { str = xstrdup(str_orig); @@ -959,12 +961,12 @@ update_bitmaps(search_mode_t mode, search_data_t * data, start = str; lmg = 0; - /* starts points to the first UTF-8 glyph of the word */ - /* """""""""""""""""""""""""""""""""""""""""""""""""" */ + /* starts points to the first UTF-8 glyph of the word. */ + /* """"""""""""""""""""""""""""""""""""""""""""""""""" */ while ((size_t)(start - str) < word_a[ |