diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-27 21:16:30 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-27 21:16:30 +0000 |
commit | 8d523cbcd79c5428f1ea5bcbec6b7d9fd3756dc3 (patch) | |
tree | 4ca49a28f56a37798fdad1488aab4b570436b7d8 | |
parent | 09f5ecfa470f0cc88fba251d04f790a3e7bf92e8 (diff) | |
download | busybox-w32-8d523cbcd79c5428f1ea5bcbec6b7d9fd3756dc3.tar.gz busybox-w32-8d523cbcd79c5428f1ea5bcbec6b7d9fd3756dc3.tar.bz2 busybox-w32-8d523cbcd79c5428f1ea5bcbec6b7d9fd3756dc3.zip |
fbset: shrink code a bit more
-rw-r--r-- | util-linux/fbset.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/util-linux/fbset.c b/util-linux/fbset.c index 5d360b75e..0ed8fae39 100644 --- a/util-linux/fbset.c +++ b/util-linux/fbset.c | |||
@@ -170,9 +170,9 @@ enum { | |||
170 | }; | 170 | }; |
171 | #endif | 171 | #endif |
172 | 172 | ||
173 | static void ss(uint32_t *x, uint32_t flag, char *where, const char *what) | 173 | static void ss(uint32_t *x, uint32_t flag, char *buf, const char *what) |
174 | { | 174 | { |
175 | if (strstr(where, what)) | 175 | if (strstr(buf, what)) |
176 | *x &= ~flag; | 176 | *x &= ~flag; |
177 | else | 177 | else |
178 | *x |= flag; | 178 | *x |= flag; |
@@ -187,8 +187,7 @@ static int readmode(struct fb_var_screeninfo *base, const char *fn, | |||
187 | char *p = buf; | 187 | char *p = buf; |
188 | 188 | ||
189 | f = xfopen_for_read(fn); | 189 | f = xfopen_for_read(fn); |
190 | while (!feof(f)) { | 190 | while (fgets(buf, sizeof(buf), f)) { |
191 | fgets(buf, sizeof(buf), f); | ||
192 | p = strstr(buf, "mode "); | 191 | p = strstr(buf, "mode "); |
193 | if (!p && !(p = strstr(buf, "mode\t"))) | 192 | if (!p && !(p = strstr(buf, "mode\t"))) |
194 | continue; | 193 | continue; |
@@ -197,13 +196,13 @@ static int readmode(struct fb_var_screeninfo *base, const char *fn, | |||
197 | continue; | 196 | continue; |
198 | p += strlen(mode); | 197 | p += strlen(mode); |
199 | if (!isspace(*p) && (*p != 0) && (*p != '"') | 198 | if (!isspace(*p) && (*p != 0) && (*p != '"') |
200 | && (*p != '\r') && (*p != '\n')) | 199 | && (*p != '\r') && (*p != '\n') |
200 | ) { | ||
201 | continue; /* almost, but not quite */ | 201 | continue; /* almost, but not quite */ |
202 | } | ||
202 | 203 | ||
203 | while (!feof(f)) { | 204 | while (fgets(buf, sizeof(buf), f)) { |
204 | fgets(buf, sizeof(buf), f); | 205 | if ((p = strstr(buf, "geometry "))) { |
205 | p = strstr(buf, "geometry "); | ||
206 | if (p) { | ||
207 | p += 9; | 206 | p += 9; |
208 | /* FIXME: catastrophic on arches with 64bit ints */ | 207 | /* FIXME: catastrophic on arches with 64bit ints */ |
209 | sscanf(p, "%d %d %d %d %d", | 208 | sscanf(p, "%d %d %d %d %d", |
@@ -245,22 +244,22 @@ static int readmode(struct fb_var_screeninfo *base, const char *fn, | |||
245 | } | 244 | } |
246 | #endif | 245 | #endif |
247 | 246 | ||
248 | static inline void setmode(struct fb_var_screeninfo *base, | 247 | static void setmode(struct fb_var_screeninfo *base, |
249 | struct fb_var_screeninfo *set) | 248 | struct fb_var_screeninfo *set) |
250 | { | 249 | { |
251 | if ((int) set->xres > 0) | 250 | if ((int32_t) set->xres > 0) |
252 | base->xres = set->xres; | 251 | base->xres = set->xres; |
253 | if ((int) set->yres > 0) | 252 | if ((int32_t) set->yres > 0) |
254 | base->yres = set->yres; | 253 | base->yres = set->yres; |
255 | if ((int) set->xres_virtual > 0) | 254 | if ((int32_t) set->xres_virtual > 0) |
256 | base->xres_virtual = set->xres_virtual; | 255 | base->xres_virtual = set->xres_virtual; |
257 | if ((int) set->yres_virtual > 0) | 256 | if ((int32_t) set->yres_virtual > 0) |
258 | base->yres_virtual = set->yres_virtual; | 257 | base->yres_virtual = set->yres_virtual; |
259 | if ((int) set->bits_per_pixel > 0) | 258 | if ((int32_t) set->bits_per_pixel > 0) |
260 | base->bits_per_pixel = set->bits_per_pixel; | 259 | base->bits_per_pixel = set->bits_per_pixel; |
261 | } | 260 | } |
262 | 261 | ||
263 | static inline void showmode(struct fb_var_screeninfo *v) | 262 | static void showmode(struct fb_var_screeninfo *v) |
264 | { | 263 | { |
265 | double drate = 0, hrate = 0, vrate = 0; | 264 | double drate = 0, hrate = 0, vrate = 0; |
266 | 265 | ||
@@ -290,12 +289,8 @@ static inline void showmode(struct fb_var_screeninfo *v) | |||
290 | v->blue.length, v->blue.offset, v->transp.length, v->transp.offset); | 289 | v->blue.length, v->blue.offset, v->transp.length, v->transp.offset); |
291 | } | 290 | } |
292 | 291 | ||
293 | #ifdef STANDALONE | ||
294 | int main(int argc, char **argv) | ||
295 | #else | ||
296 | int fbset_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 292 | int fbset_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
297 | int fbset_main(int argc, char **argv) | 293 | int fbset_main(int argc, char **argv) |
298 | #endif | ||
299 | { | 294 | { |
300 | struct fb_var_screeninfo var, varset; | 295 | struct fb_var_screeninfo var, varset; |
301 | int fh, i; | 296 | int fh, i; |