[MPlayer-dev-eng] [PATCH] Bug fix for -geometry option NODAEMON

Bjorn Danielsson mplayer-mail at dax.nu
Tue Feb 1 11:35:03 CET 2005


Diego Biurrun <diego at biurrun.de> wrote:
> Bjorn Danielsson writes:
> > The manual page says that "%" appended to an x or y position
> > causes the corresponding value to be interpreted as a percentage
> > of screen width/height instead of an absolute pixel offset.
> > 
> > The code doesn't agree, it applies this interpretation to both
> > x and y even if only one of the coordinates has a "%" suffix.
> > The attached patch makes the code agree with the manual, which
> > in my opinion is more sensible in this case.
> 
> Rejected.  Your patch still has problems.  While it does fix some
> cases, now e.g. -geometry 100%:50% does not work as it should anymore.

Ah, there were more subtleties than I recognized at first.
Since sscanf reports successful assignments even when the trailing
text doesn't match, the last % must always be explicitly matched
and the matching order rearranged so the longest match is tried
first. Here is an updated patch, which I have tested a bit more
thoroughly (sorry about that).

-------------- next part --------------
Index: libvo/geometry.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/geometry.c,v
retrieving revision 1.13
diff -u -r1.13 geometry.c
--- libvo/geometry.c	28 Oct 2004 01:15:52 -0000	1.13
+++ libvo/geometry.c	1 Feb 2005 10:17:16 -0000
@@ -31,20 +31,21 @@
 		  RESET_GEOMETRY
 		  if(sscanf(vo_geometry, "+%i+%i", &xoff, &yoff) != 2)
 		  {
+		   char percent[2];
 		   RESET_GEOMETRY
-		   if(sscanf(vo_geometry, "%i:%i", &xoff, &yoff) != 2)
+		   if(sscanf(vo_geometry, "%i%%:%i%1[%]", &xper, &yper, &percent) != 3)
 		   {
 		    RESET_GEOMETRY
-		    if(sscanf(vo_geometry, "%i:%i%%", &xper, &yper) != 2)
+		    if(sscanf(vo_geometry, "%i:%i%1[%]", &xoff, &yper, &percent) != 3)
 		    {
 		     RESET_GEOMETRY
-		     if(sscanf(vo_geometry, "%i%%:%i", &xper, &yper) != 2)
+		     if(sscanf(vo_geometry, "%i%%:%i", &xper, &yoff) != 2)
 		     {
 		     RESET_GEOMETRY
-		     if(sscanf(vo_geometry, "%i%%:%i%%", &xper, &yper) != 2)
+		     if(sscanf(vo_geometry, "%i:%i", &xoff, &yoff) != 2)
 		     {
 		      RESET_GEOMETRY
-		      if(sscanf(vo_geometry, "%i%%", &xper) != 1)
+		      if(sscanf(vo_geometry, "%i%1[%]", &xper, &percent) != 2)
 		      {
 			mp_msg(MSGT_VO, MSGL_ERR,
 			    "-geometry must be in [WxH][+X+Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry);
-------------- next part --------------


-- 
Bjorn Danielsson  <mplayer-mail at dax.nu>


More information about the MPlayer-dev-eng mailing list