[gtk-doc] gtkdocize: Fix GTK_DOC_CHECK argument handling



commit d59906d0ed9085331b8b442d5c794d2fe1dc794b
Author: David King <amigadave amigadave com>
Date:   Thu Sep 5 19:33:11 2013 +0100

    gtkdocize: Fix GTK_DOC_CHECK argument handling
    
    After commit 1401aebc625dd1c7c39457d3455dce3019ded0be, any extra
    arguments passed to gtkdocize by GTK_DOC_CHECK in configure.ac were
    ignored. This broke because the arguments to GTK_DOC_CHECK are injected
    into the argument for gtkdocize, but the rearrangement to add --srcdir
    support pushed the injection down to after where the arguments were
    parsed.
    
    Fix the argument handling by checking for a --srcdir agument (and for
    GTK_DOC_CHECK) before parsing other arguments.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=707426

 gtkdocize.in |   88 +++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 53 insertions(+), 35 deletions(-)
---
diff --git a/gtkdocize.in b/gtkdocize.in
index 9164ac4..06b67a5 100644
--- a/gtkdocize.in
+++ b/gtkdocize.in
@@ -19,6 +19,57 @@ flavour=legacy
 usage="\
 usage: $progname [ --copy ] [ --docdir DIR ] [ --flavour {legacy|legacy-flat|no-tmpl|no-tmpl-flat} ] [ 
--srcdir DIR ]"
 
+# Find the srcdir early (and ignore a srcdir set in configure).
+# https://bugzilla.gnome.org/show_bug.cgi?id=707426
+args="$*"
+while test $# -gt 0; do
+  case "$1" in
+  --srcdir)
+    shift
+    srcdir="$1"
+    shift ;;
+  --srcdir=*)
+    srcdir=`expr "X$1" : '[^=]*=\(.*\)'`
+    shift ;;
+  *)
+    shift ;;
+  esac
+done
+set - $args
+
+# assume working directory if srcdir is not set
+test "$srcdir" || srcdir=.
+test "$docdir" || docdir="$srcdir"
+
+# detect configure script
+no_configure_found=0
+if test -f "$srcdir"/configure.ac; then
+  configure="$srcdir"/configure.ac
+elif test -f "$srcdir"/configure.in; then
+  configure="$srcdir"/configure.in
+else
+  no_configure_found=1
+fi
+
+# check configure script for GTK_DOC_CHECK macro
+no_gtk_doc_check_found=0
+if test $no_configure_found -eq 0; then
+  macro=`grep '^GTK_DOC_CHECK' $configure 2>/dev/null`
+  if test $? -eq 0; then
+    # GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
+    params=`echo $macro | sed -e 's/^GTK_DOC_CHECK(\ *\(.*\))/\1/'`
+    if echo $params | grep -q '^.*\,\ *\[\{0,1\}'; then
+      extra_options=`echo $params | sed -e 's/^.*\,\ *\[\{0,1\}\([^]]*\)\]\{0,1\}\ *$/\1/'`
+      #echo >&2 "DEBUG: adding extra options [$extra_options] to [$*]"
+      set - $* $GTKDOCIZE_FLAGS $extra_options
+    else
+      set - $* $GTKDOCIZE_FLAGS
+    fi
+  else
+    no_gtk_doc_check_found=1;
+  fi
+fi
+
 while test $# -gt 0; do
   #echo >&2 "DEBUG: parsing args [$1]";
   case "$1" in
@@ -47,10 +98,10 @@ while test $# -gt 0; do
     shift ;;
   --srcdir)
     shift
-    srcdir="$1"
+    # srcdir was set earlier.
     shift ;;
   --srcdir=*)
-    srcdir=`expr "X$1" : '[^=]*=\(.*\)'`
+    # srcdir was set earlier.
     shift ;;
   -*)
     echo "$progname: unrecognised option '$1'" 1>&2
@@ -81,39 +132,6 @@ case "$flavour" in
     exit 1 ;;
 esac
 
-# assume working directory if srcdir is not set
-test "$srcdir" || srcdir=.
-test "$docdir" || docdir="$srcdir"
-
-# detect configure script
-no_configure_found=0
-if test -f "$srcdir"/configure.ac; then
-  configure="$srcdir"/configure.ac
-elif test -f "$srcdir"/configure.in; then
-  configure="$srcdir"/configure.in
-else
-  no_configure_found=1
-fi
-
-# check configure script for GTK_DOC_CHECK macro
-no_gtk_doc_check_found=0
-if test $no_configure_found -eq 0; then
-  macro=`grep '^GTK_DOC_CHECK' $configure 2>/dev/null`
-  if test $? -eq 0; then
-    # GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
-    params=`echo $macro | sed -e 's/^GTK_DOC_CHECK(\ *\(.*\))/\1/'`
-    if echo $params | grep -q '^.*\,\ *\[\{0,1\}'; then
-      extra_options=`echo $params | sed -e 's/^.*\,\ *\[\{0,1\}\([^]]*\)\]\{0,1\}\ *$/\1/'`
-      #echo >&2 "DEBUG: adding extra options [$extra_options] to [$*]"
-      set - $* $GTKDOCIZE_FLAGS $extra_options
-    else
-      set - $* $GTKDOCIZE_FLAGS
-    fi
-  else
-    no_gtk_doc_check_found=1;
-  fi
-fi
-
 if test $no_configure_found -eq 1; then
   echo "$progname: neither configure.ac nor configure.in exist" 1>&2
   exit 1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]