diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/text_editor.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/apps/plugins/text_editor.c b/apps/plugins/text_editor.c index 82c5e49632..911b64e7ab 100644 --- a/apps/plugins/text_editor.c +++ b/apps/plugins/text_editor.c | |||
@@ -136,31 +136,34 @@ char *list_get_name_cb(int selected_item, void* data, | |||
136 | else rb->strncpy(buf, b, buf_len); | 136 | else rb->strncpy(buf, b, buf_len); |
137 | return buf; | 137 | return buf; |
138 | } | 138 | } |
139 | |||
139 | char filename[MAX_PATH]; | 140 | char filename[MAX_PATH]; |
140 | int get_eol_string(char* fn) | 141 | int get_eol_string(char* fn) |
141 | { | 142 | { |
142 | int fd=-1; | 143 | int fd, result; |
143 | char t; | 144 | char t; |
144 | if (!fn) | 145 | |
145 | return 0; | 146 | if (!fn || !fn[0]) |
146 | else if (!fn[0]) | ||
147 | return 0; | 147 | return 0; |
148 | fd = rb->open(fn,O_RDONLY); | 148 | fd = rb->open(fn,O_RDONLY); |
149 | if (fd<0) | 149 | if (fd<0) |
150 | return 0; | 150 | return 0; |
151 | |||
151 | eol[0] = '\0'; | 152 | eol[0] = '\0'; |
153 | result = 1; | ||
152 | while (!eol[0]) | 154 | while (!eol[0]) |
153 | { | 155 | { |
154 | if (!rb->read(fd,&t,1)) | 156 | if (!rb->read(fd,&t,1)) |
155 | { | 157 | { |
156 | rb->strcpy(eol,"\n"); | 158 | rb->strcpy(eol,"\n"); |
157 | return 0; | 159 | result = 0; |
158 | } | 160 | } |
159 | if (t == '\r') | 161 | if (t == '\r') |
160 | { | 162 | { |
161 | if (rb->read(fd,&t,1) && t=='\n') | 163 | if (rb->read(fd,&t,1) && t=='\n') |
162 | rb->strcpy(eol,"\r\n"); | 164 | rb->strcpy(eol,"\r\n"); |
163 | else rb->strcpy(eol,"\r"); | 165 | else |
166 | rb->strcpy(eol,"\r"); | ||
164 | } | 167 | } |
165 | else if (t == '\n') | 168 | else if (t == '\n') |
166 | { | 169 | { |
@@ -168,7 +171,7 @@ int get_eol_string(char* fn) | |||
168 | } | 171 | } |
169 | } | 172 | } |
170 | rb->close(fd); | 173 | rb->close(fd); |
171 | return 1; | 174 | return result; |
172 | } | 175 | } |
173 | 176 | ||
174 | void save_changes(int overwrite) | 177 | void save_changes(int overwrite) |