2015-08-13 Benno Schulenberg <bensberg@justemail.net>
* src/search.c (do_find_bracket): Remove mistaken comparison between
pointer and literal character. Found with cppcheck.
+ * src/browser.c (browser_init): Speed up the finding of the longest
+ filename: don't limit the value to that of COLS all the time, as this
+ is done later anyway, and don't bother skipping the dot entry.
2015-08-12 Benno Schulenberg <bensberg@justemail.net>
* src/chars.c: UTF-8 is a stateless encoding, so there is no need to
assert(path != NULL && path[strlen(path) - 1] == '/' && dir != NULL);
- /* Set longest to zero, just before we initialize it. */
longest = 0;
+ /* Find the length of the longest filename in the current folder. */
while ((nextdir = readdir(dir)) != NULL) {
- size_t d_len;
+ size_t name_len = strlenpt(nextdir->d_name);
- /* Don't show the "." entry. */
- if (strcmp(nextdir->d_name, ".") == 0)
- continue;
-
- d_len = strlenpt(nextdir->d_name);
- if (d_len > longest)
- longest = (d_len > COLS) ? COLS : d_len;
+ if (name_len > longest)
+ longest = name_len;
i++;
}
- rewinddir(dir);
-
- /* Put 10 columns' worth of blank space between columns of filenames
+ /* Put 10 characters' worth of blank space between columns of filenames
* in the list whenever possible, as Pico does. */
longest += 10;
+ /* Make sure longest is between 15 and COLS. */
+ if (longest < 15)
+ longest = 15;
+ if (longest > COLS)
+ longest = COLS;
+
+ rewinddir(dir);
+
if (filelist != NULL)
free_chararray(filelist, filelist_len);
closedir(dir);
- /* Make sure longest is between 15 and COLS. */
- if (longest < 15)
- longest = 15;
- if (longest > COLS)
- longest = COLS;
-
/* Set width to zero, just before we initialize it. */
width = 0;