mirror of https://github.com/mpv-player/mpv
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
This commit is contained in:
parent
9beeeb1a9e
commit
55b3c6f090
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue