diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2010-03-03 20:24:46 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2010-03-03 20:24:46 +0000 |
commit | 55b3c6f0901e7240a4360007c2bc98f372b8e127 (patch) | |
tree | fe767dbb0ecf439f5fa8d35138896e79ea5df7de /libvo/geometry.c | |
parent | 9beeeb1a9ecec3916f16e8315edc026b7f48ac21 (diff) | |
download | mpv-55b3c6f0901e7240a4360007c2bc98f372b8e127.tar.bz2 mpv-55b3c6f0901e7240a4360007c2bc98f372b8e127.tar.xz |
Avoid very deep indentation level and RESET_GEOMETRY macro in -geometry
parsing.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30820 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo/geometry.c')
-rw-r--r-- | libvo/geometry.c | 73 |
1 files changed, 34 insertions, 39 deletions
diff --git a/libvo/geometry.c b/libvo/geometry.c index 056a05facb..ec9e7f0a5f 100644 --- a/libvo/geometry.c +++ b/libvo/geometry.c @@ -30,53 +30,50 @@ char *vo_geometry; int geometry_wh_changed; int geometry_xy_changed; -#define RESET_GEOMETRY width = height = xoff = yoff = xper = yper = INT_MIN; - // xpos,ypos: position of the left upper corner // widw,widh: width and height of the window // scrw,scrh: width and height of the current screen int geometry(int *xpos, int *ypos, int *widw, int *widh, int scrw, int scrh) { - int width, height, xoff, yoff, xper, yper; - - RESET_GEOMETRY - if(vo_geometry != NULL) { - if(sscanf(vo_geometry, "%ix%i+%i+%i", &width, &height, &xoff, &yoff) != 4 ) - { - RESET_GEOMETRY - if(sscanf(vo_geometry, "%ix%i", &width, &height) != 2) - { - RESET_GEOMETRY - if(sscanf(vo_geometry, "+%i+%i", &xoff, &yoff) != 2) - { - char percent[2]; - RESET_GEOMETRY - if(sscanf(vo_geometry, "%i%%:%i%1[%]", &xper, &yper, percent) != 3) - { - RESET_GEOMETRY - if(sscanf(vo_geometry, "%i:%i%1[%]", &xoff, &yper, percent) != 3) - { - RESET_GEOMETRY - if(sscanf(vo_geometry, "%i%%:%i", &xper, &yoff) != 2) - { - RESET_GEOMETRY - if(sscanf(vo_geometry, "%i:%i", &xoff, &yoff) != 2) - { - RESET_GEOMETRY - if(sscanf(vo_geometry, "%i%1[%]", &xper, percent) != 2) - { + int width, height, xoff, yoff, xper, yper; + int i; + int ok = 0; + for (i = 0; !ok && i < 8; i++) { + char percent[2]; + width = height = xoff = yoff = xper = yper = INT_MIN; + switch (i) { + case 0: + ok = sscanf(vo_geometry, "%ix%i+%i+%i", &width, &height, &xoff, &yoff) == 4; + break; + case 1: + ok = sscanf(vo_geometry, "%ix%i", &width, &height) == 2; + break; + case 2: + ok = sscanf(vo_geometry, "+%i+%i", &xoff, &yoff) == 2; + break; + case 3: + ok = sscanf(vo_geometry, "%i%%:%i%1[%]", &xper, &yper, percent) == 3; + break; + case 4: + ok = sscanf(vo_geometry, "%i:%i%1[%]", &xoff, &yper, percent) == 3; + break; + case 5: + ok = sscanf(vo_geometry, "%i%%:%i", &xper, &yoff) == 2; + break; + case 6: + ok = sscanf(vo_geometry, "%i:%i", &xoff, &yoff) == 2; + break; + case 7: + ok = sscanf(vo_geometry, "%i%1[%]", &xper, percent) == 2; + break; + } + } + if (!ok) { mp_msg(MSGT_VO, MSGL_ERR, "-geometry must be in [WxH][+X+Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry); return 0; } - } - } - } - } - } - } - } mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i," "height: %i, xoff: %i, yoff: %i, xper: %i, yper: %i\n", @@ -101,5 +98,3 @@ int geometry(int *xpos, int *ypos, int *widw, int *widh, int scrw, int scrh) } return 1; } - -#undef RESET_GEOMETRY |