Convert the minority of while() to while ().
authorLaurent Monin <geeqie@norz.org>
Thu, 24 Apr 2008 15:49:57 +0000 (15:49 +0000)
committerLaurent Monin <geeqie@norz.org>
Thu, 24 Apr 2008 15:49:57 +0000 (15:49 +0000)
15 files changed:
src/bar_info.c
src/cache_maint.c
src/collect-table.c
src/collect.c
src/dupe.c
src/editors.c
src/exif-common.c
src/pan-view.c
src/rcfile.c
src/slideshow.c
src/thumb.c
src/ui_bookmark.c
src/ui_fileops.c
src/ui_tabcomp.c
src/view_file_icon.c

index 86bc82a..f08a999 100644 (file)
@@ -152,7 +152,7 @@ static gint comment_file_read(gchar *path, GList **keywords, gchar **comment)
                        gchar *keystr = ++ptr;
                        
                        key = MK_NONE;
-                       while(*ptr != ']' && *ptr != '\n' && *ptr != '\0') ptr++;
+                       while (*ptr != ']' && *ptr != '\n' && *ptr != '\0') ptr++;
                        
                        if (*ptr == ']')
                                {
index c2b75c2..cffd5bc 100644 (file)
@@ -368,7 +368,7 @@ gint cache_maintain_home_dir(const gchar *dir, gint recursive, gint clear)
                GList *work;
 
                work = dlist;
-               while(work)
+               while (work)
                        {
                        gchar *path = work->data;
                        if (recursive && strlen(path) > base_length &&
index 45eb213..4d9c036 100644 (file)
@@ -293,7 +293,7 @@ void collection_table_select_all(CollectTable *ct)
        ct->selection = NULL;
 
        work = ct->cd->list;
-       while(work)
+       while (work)
                {
                ct->selection = g_list_append(ct->selection, work->data);
                collection_table_selection_add(ct, work->data, SELECTION_SELECTED, NULL);
@@ -895,7 +895,7 @@ static void collection_table_move_focus(CollectTable *ct, gint row, gint col, gi
                if (new_row < 0) new_row = 0;
                if (new_row >= ct->rows) new_row = ct->rows - 1;
 
-               while(col != 0)
+               while (col != 0)
                        {
                        if (col < 0)
                                {
index 60b21b7..f1f2ad6 100644 (file)
@@ -114,7 +114,7 @@ void collection_list_free(GList *list)
 {
        GList *work;
        work = list;
-       while(work)
+       while (work)
                {
                collection_info_free((CollectInfo *)work->data);
                work = work->next;
@@ -215,7 +215,7 @@ CollectInfo *collection_list_find(GList *list, const gchar *path)
 {
        GList *work = list;
 
-       while(work)
+       while (work)
                {
                CollectInfo *ci = work->data;
                if (strcmp(ci->fd->path, path) == 0) return ci;
@@ -230,7 +230,7 @@ static GList *collection_list_find_link(GList *list, gchar *path)
 {
        GList *work = list;
 
-       while(work)
+       while (work)
                {
                CollectInfo *ci = work->data;
                if (strcmp(ci->fd->path, path) == 0) return work;
@@ -245,7 +245,7 @@ static gint collection_list_find_index(GList *list, gchar *path)
        gint c = 0;
        GList *work = list;
 
-       while(work)
+       while (work)
                {
                CollectInfo *ci = work->data;
                if (strcmp(ci->fd->path, path) == 0) return c;
@@ -436,7 +436,7 @@ CollectionData *collection_from_dnd_data(const gchar *data, GList **list, GList
                gint b, e;
 
                b = 0;
-               while(data[b] != '\0' && data[b] != '\n' ) b++;
+               while (data[b] != '\0' && data[b] != '\n' ) b++;
                b++;
                e = b;
 
@@ -481,7 +481,7 @@ gchar *collection_info_list_to_dnd_data(CollectionData *cd, GList *list, gint *l
        temp = NULL;
        temp = g_list_prepend(temp, g_strdup_printf("COLLECTION:%d\n", n));
        work = list;
-       while(work)
+       while (work)
                {
                n = g_list_index(cd->list, work->data);
                if (n >= 0)
@@ -493,7 +493,7 @@ gchar *collection_info_list_to_dnd_data(CollectionData *cd, GList *list, gint *l
 
        total = 0;
        work = temp;
-       while(work)
+       while (work)
                {
                total += strlen((gchar *)work->data);
                work = work->next;
@@ -504,7 +504,7 @@ gchar *collection_info_list_to_dnd_data(CollectionData *cd, GList *list, gint *l
        ptr = uri_text;
 
        work = g_list_last(temp);
-       while(work)
+       while (work)
                {
                gchar *text = work->data;
 
@@ -718,7 +718,7 @@ void collection_remove_by_info_list(CollectionData *cd, GList *list)
                }
 
        work = list;
-       while(work)
+       while (work)
                {
                cd->list = collection_list_remove(cd->list, work->data);
                work = work->next;
@@ -762,12 +762,12 @@ void collection_maint_removed(FileData *fd)
        GList *work;
 
        work = collection_list;
-       while(work)
+       while (work)
                {
                CollectionData *cd = work->data;
                work = work->next;
 
-               while(collection_remove(cd, fd));
+               while (collection_remove(cd, fd));
                }
 #if 0
        /* Do we really need to do this? removed files are
@@ -782,12 +782,12 @@ void collection_maint_renamed(FileData *fd)
        GList *work;
 
        work = collection_list;
-       while(work)
+       while (work)
                {
                CollectionData *cd = work->data;
                work = work->next;
 
-               while(collection_rename(cd, fd));
+               while (collection_rename(cd, fd));
                }
 
        collect_manager_moved(fd);
index 54b149c..aa00784 100644 (file)
@@ -1741,14 +1741,14 @@ static void dupe_files_add(DupeWindow *dw, CollectionData *collection, CollectIn
                                d = filelist_filter(d, TRUE);
 
                                work = f;
-                               while(work)
+                               while (work)
                                        {
                                        dupe_files_add(dw, NULL, NULL, (FileData *)work->data, TRUE);
                                        work = work->next;
                                        }
                                filelist_free(f);
                                work = d;
-                               while(work)
+                               while (work)
                                        {
                                        dupe_files_add(dw, NULL, NULL, (FileData *)work->data, TRUE);
                                        work = work->next;
@@ -1775,7 +1775,7 @@ void dupe_window_add_collection(DupeWindow *dw, CollectionData *collection)
        CollectInfo *info;
 
        info = collection_get_first(collection);
-       while(info)
+       while (info)
                {
                dupe_files_add(dw, collection, info, NULL, FALSE);
                info = collection_next_by_info(collection, info);
@@ -1789,7 +1789,7 @@ void dupe_window_add_files(DupeWindow *dw, GList *list, gint recurse)
        GList *work;
 
        work = list;
-       while(work)
+       while (work)
                {
                FileData *fd = work->data;
                work = work->next;
@@ -3431,7 +3431,7 @@ static void dupe_dnd_data_get(GtkWidget *widget, GdkDragContext *context,
                case TARGET_URI_LIST:
                        list = uri_filelist_from_text((gchar *)selection_data->data, TRUE);
                        work = list;
-                       while(work)
+                       while (work)
                                {
                                FileData *fd = work->data;
                                if (isdir(fd->path))
index 9b3f6d7..3b120d2 100644 (file)
@@ -288,7 +288,7 @@ static gchar *editor_command_path_parse(const FileData *fd, PathType type, const
                        p = fd->path;
                else
                        {
-                       while(work)
+                       while (work)
                                {
                                GList *work2;
                                gchar *ext = work->data;
@@ -302,7 +302,7 @@ static gchar *editor_command_path_parse(const FileData *fd, PathType type, const
                                        }
 
                                work2 = fd->sidecar_files;
-                               while(work2)
+                               while (work2)
                                        {
                                        FileData *sfd = work2->data;
                                        work2 = work2->next;
index 8889116..beab1a3 100644 (file)
@@ -165,7 +165,7 @@ gchar *exif_get_formatted_by_key(ExifData *exif, const gchar *key, gint *key_val
 do {                                    \
        if (g_str_has_suffix(str,suff)) \
                str[strlen(str)-(sizeof(suff)-1)] = 0;  \
-} while(0)
+} while (0)
                        REMOVE_SUFFIX(make," Corporation"); /* Pentax */
                        REMOVE_SUFFIX(make," OPTICAL CO.,LTD"); /* OLYMPUS */
                        REMOVE_SUFFIX(make," CORPORATION"); /* Nikon */
@@ -500,7 +500,7 @@ ExifData *exif_read_fd(FileData *fd)
 
        if (filter_file_class(fd->extension, FORMAT_CLASS_RAWIMAGE))
                {
-               while(work)
+               while (work)
                        {
                        FileData *sfd = work->data;
                        work = work->next;
index aee4081..24b96be 100644 (file)
@@ -256,7 +256,7 @@ static void pan_queue_add(PanWindow *pw, PanItem *pi)
        pi->queued = TRUE;
        pw->queue = g_list_prepend(pw->queue, pi);
 
-       if (!pw->tl && !pw->il) while(pan_queue_step(pw));
+       if (!pw->tl && !pw->il) while (pan_queue_step(pw));
 }
 
 
index 74a991f..dc61492 100644 (file)
@@ -582,18 +582,18 @@ void load_options(void)
                gchar *option_start, *value_start;
                gchar *p = s_buf;
 
-               while(g_ascii_isspace(*p)) p++;
+               while (g_ascii_isspace(*p)) p++;
                if (!*p || *p == '\n' || *p == '#') continue;
                option_start = p;
-               while(*p && *p != ':') p++;
+               while (*p && *p != ':') p++;
                if (!*p) continue;
                *p = '\0';
                p++;
                strncpy(option, option_start, sizeof(option));
-               while(g_ascii_isspace(*p)) p++;
+               while (g_ascii_isspace(*p)) p++;
                value_start = p;
                strncpy(value_all, value_start, sizeof(value_all));
-               while(*p && !g_ascii_isspace(*p) && *p != '\n') p++;
+               while (*p && !g_ascii_isspace(*p) && *p != '\n') p++;
                *p = '\0';
                strncpy(value, value_start, sizeof(value));
 
index 6f03ad5..9288518 100644 (file)
@@ -74,7 +74,7 @@ static GList *generate_random_list(SlideShowData *ss)
 
        src_list = generate_list(ss);
 
-       while(src_list)
+       while (src_list)
                {
                gint p = (double)rand() / ((double)RAND_MAX + 1.0) * g_list_length(src_list);
                work = g_list_nth(src_list, p);
@@ -107,7 +107,7 @@ static void slideshow_list_init(SlideShowData *ss, gint start_index)
                        /* start with specified image by skipping to it */
                        gint i = 0;
 
-                       while(ss->list && i < start_index)
+                       while (ss->list && i < start_index)
                                {
                                ss->list_done = g_list_prepend(ss->list_done, ss->list->data);
                                ss->list = g_list_remove(ss->list, ss->list->data);
index 016c349..19262c9 100644 (file)
@@ -564,7 +564,7 @@ static guchar *load_xv_thumbnail(gchar *filename, gint *widthp, gint *heightp)
                return NULL;
                }
 
-       while(fgets(buffer, XV_BUFFER, file) && buffer[0] == '#') /* do_nothing() */;
+       while (fgets(buffer, XV_BUFFER, file) && buffer[0] == '#') /* do_nothing() */;
 
        if(sscanf(buffer, "%d %d %d", &width, &height, &depth) != 3)
                {
index 0bad364..432b97d 100644 (file)
@@ -112,7 +112,7 @@ gint history_list_load(const gchar *path)
 
                        ptr = s_buf + 1;
                        c = 0;
-                       while(ptr[c] != ']' && ptr[c] != '\n' && ptr[c] != '\0') c++;
+                       while (ptr[c] != ']' && ptr[c] != '\n' && ptr[c] != '\0') c++;
 
                        g_free(key);
                        key = g_strndup(ptr, c);
@@ -155,7 +155,7 @@ gint history_list_save(const gchar *path)
        secure_fprintf(ssi, "#History lists\n\n");
 
        list = g_list_last(history_list);
-       while(list && secsave_errno == SS_ERR_NONE)
+       while (list && secsave_errno == SS_ERR_NONE)
                {
                HistoryData *hd;
                GList *work;
@@ -169,7 +169,7 @@ gint history_list_save(const gchar *path)
                 * so that when reading they are added correctly
                 */
                work = g_list_last(hd->list);
-               while(work && secsave_errno == SS_ERR_NONE)
+               while (work && secsave_errno == SS_ERR_NONE)
                        {
                        secure_fprintf(ssi, "\"%s\"\n", (gchar *)work->data);
                        work = work->prev;
@@ -189,7 +189,7 @@ static void history_list_free(HistoryData *hd)
        if (!hd) return;
 
        work = hd->list;
-       while(work)
+       while (work)
                {
                g_free(work->data);
                work = work->next;
@@ -252,7 +252,7 @@ void history_list_add_to_key(const gchar *key, const gchar *path, gint max)
 
        /* if already in the list, simply move it to the top */
        work = hd->list;
-       while(work)
+       while (work)
                {
                gchar *buf = work->data;
                work = work->next;
@@ -269,7 +269,7 @@ void history_list_add_to_key(const gchar *key, const gchar *path, gint max)
        if (max == -1) max = HISTORY_DEFAULT_KEY_COUNT;
        if (max > 0)
                {
-               while(hd->list && g_list_length(hd->list) > max)
+               while (hd->list && g_list_length(hd->list) > max)
                        {
                        GList *work = g_list_last(hd->list);
                        gchar *buf = work->data;
@@ -289,7 +289,7 @@ void history_list_item_change(const gchar *key, const gchar *oldpath, const gcha
        if (!hd) return;
 
        work = hd->list;
-       while(work)
+       while (work)
                {
                gchar *buf = work->data;
                if (strcmp(buf, oldpath) == 0)
@@ -1356,7 +1356,7 @@ void uri_text_decode(gchar *text)
 
                w = r = text;
 
-               while(*r != '\0')
+               while (*r != '\0')
                        {
                        if (*r == '%' && *(r + 1) != '\0' && *(r + 2) != '\0')
                                {
index 0a26c8a..7aba01a 100644 (file)
@@ -426,7 +426,7 @@ gint copy_file(const gchar *s, const gchar *t)
 
        if (!fi || !fo) return FALSE;
 
-       while((b = fread(buf, sizeof(char), sizeof(buf), fi)) && b != 0)
+       while ((b = fread(buf, sizeof(char), sizeof(buf), fi)) && b != 0)
                {
                if (fwrite(buf, sizeof(char), b, fo) != b)
                        {
@@ -634,7 +634,7 @@ long checksum_simple(const gchar *path)
        g_free(path8);
        if (!f) return -1;
 
-       while((c = fgetc(f)) != EOF)
+       while ((c = fgetc(f)) != EOF)
                {
                sum += c;
                }
@@ -727,7 +727,7 @@ gchar *remove_level_from_path(const gchar *path)
 
        p = strlen(path) - 1;
        if (p < 0) return NULL;
-       while(ptr[p] != '/' && p > 0) p--;
+       while (ptr[p] != '/' && p > 0) p--;
        if (p == 0 && ptr[p] == '/') p++;
        new_path = g_strndup(path, (guint)p);
        return new_path;
@@ -772,7 +772,7 @@ gchar *remove_extension_from_path(const gchar *path)
        if (strlen(path) < 2) return g_strdup(path);
 
        p = strlen(path) - 1;
-       while(ptr[p] != '.' && p > 0) p--;
+       while (ptr[p] != '.' && p > 0) p--;
        if (p == 0) p = strlen(path) - 1;
        new_path = g_strndup(path, (guint)p);
        return new_path;
index 76648e1..0b904d1 100644 (file)
@@ -88,7 +88,7 @@ static void tab_completion_free_list(TabCompData *td)
 
        list = td->file_list;
 
-       while(list)
+       while (list)
                {
                g_free(list->data);
                list = list->next;
@@ -457,7 +457,7 @@ static gint tab_completion_do(TabCompData *td)
                if (strcmp(entry_dir, "/") == 0) entry_dir[0] = '\0';
 
                list = td->file_list;
-               while(list)
+               while (list)
                        {
                        gchar *file = list->data;
                        if (strncmp(entry_file, file, l) == 0)
@@ -498,7 +498,7 @@ static gint tab_completion_do(TabCompData *td)
                                        {
                                        list = poss;
                                        if (!list) done = TRUE;
-                                       while(list && !done)
+                                       while (list && !done)
                                                {
                                                gchar *file = list->data;
                                                if (strlen(file) < c || strncmp(test_file, file, c) != 0)
index 3d334fc..efeac8d 100644 (file)
@@ -1122,7 +1122,7 @@ static void vficon_move_focus(ViewFileIcon *vfi, gint row, gint col, gint relati
                if (new_row < 0) new_row = 0;
                if (new_row >= vfi->rows) new_row = vfi->rows - 1;
 
-               while(col != 0)
+               while (col != 0)
                        {
                        if (col < 0)
                                {