commit cda97e767b75b39a0f8cc7a83b51b0e8aafa5ea3 Author: Alexei Matveev Date: Fri Apr 26 17:50:51 2013 +0200 Fix parsing long options in the command line Remove this patch once upstream sources are updated. This change is both in the most recent 3.2 and later versions. diff --git a/debian/changelog b/debian/changelog index 81b2fd0..bed0d1c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +petsc (3.2.dfsg-7) unstable; urgency=low + + * Fix parsing long options in the command line + - debian/patches/allow-keys-starting-with-double-dash.patch added + - debian/patches/series append another patch + + -- Alexei Matveev Fri, 26 Apr 2013 17:14:45 +0200 + petsc (3.2.dfsg-6) unstable; urgency=low * Team upload. diff --git a/debian/patches/allow-keys-starting-with-double-dash.patch b/debian/patches/allow-keys-starting-with-double-dash.patch new file mode 100644 index 0000000..ee0f7b5 --- /dev/null +++ b/debian/patches/allow-keys-starting-with-double-dash.patch @@ -0,0 +1,65 @@ + +This is the upstream commit + + commit 7cd08cec2432658160c70b3c529f243c3b7cdafe + Author: Jed Brown + Date: Tue Feb 28 13:45:41 2012 -0600 + +backported to 3.2 as + + commit b19a531175d4f57030c04f86a1b837c9b49a7e11 + + Allow keys starting with --, handle prefixes as --prefix_option instead of -prefix_-option. + + (cherry picked from commit 7cd08cec2432658160c70b3c529f243c3b7cdafe at + the request of Alex Matveev for Debian Wheezy) + +diff --git a/src/sys/objects/options.c b/src/sys/objects/options.c +index 9ed9f61..c7f23dd 100644 +--- a/src/sys/objects/options.c ++++ b/src/sys/objects/options.c +@@ -235,7 +235,7 @@ PetscErrorCode PetscSetProgramName(const char name[]) + #undef __FUNCT__ + #define __FUNCT__ "PetscOptionsValidKey" + /*@ +- PetscOptionsValidKey - PETSc Options database keys must begin with a - followed by a letter. ++ PetscOptionsValidKey - PETSc Options database keys must begin with one or two dashes (-) followed by a letter. + + Input Parameter: + . in_str - string to check if valid +@@ -252,7 +252,8 @@ PetscErrorCode PetscOptionsValidKey(const char in_str[],PetscBool *key) + *key = PETSC_FALSE; + if (!in_str) PetscFunctionReturn(0); + if (in_str[0] != '-') PetscFunctionReturn(0); +- if (!(isalpha(in_str[1]))) PetscFunctionReturn(0); ++ if (in_str[1] == '-') in_str++; ++ if (!isalpha(in_str[1])) PetscFunctionReturn(0); + if ((!strncmp(in_str+1,"inf",3) || !strncmp(in_str+1,"INF",3)) && !(in_str[4] == '_' || isalnum(in_str[4]))) PetscFunctionReturn(0); + *key = PETSC_TRUE; + PetscFunctionReturn(0); +@@ -1112,14 +1113,21 @@ static PetscErrorCode PetscOptionsFindPair_Private(const char pre[],const char n + + if (name[0] != '-') SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Name must begin with -: Instead %s",name); + +- /* append prefix to name */ ++ /* append prefix to name, if prefix="foo_" and option='--bar", prefixed option is --foo_bar */ + if (pre) { ++ char *ptr = tmp; + if (pre[0] == '-') SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Prefix should not begin with a -"); +- ierr = PetscStrncpy(tmp,pre,256);CHKERRQ(ierr); ++ if (name[1] == '-') { ++ *ptr++ = '-'; ++ name++; ++ } ++ ierr = PetscStrncpy(ptr,pre,tmp+sizeof tmp-ptr);CHKERRQ(ierr); ++ tmp[sizeof tmp-1] = 0; + ierr = PetscStrlen(tmp,&len);CHKERRQ(ierr); +- ierr = PetscStrncat(tmp,name+1,256-len-1);CHKERRQ(ierr); ++ ierr = PetscStrncat(tmp,name+1,sizeof tmp-len-1);CHKERRQ(ierr); + } else { +- ierr = PetscStrncpy(tmp,name+1,256);CHKERRQ(ierr); ++ ierr = PetscStrncpy(tmp,name+1,sizeof tmp);CHKERRQ(ierr); ++ tmp[sizeof tmp-1] = 0; + } + + /* slow search */ diff --git a/debian/patches/series b/debian/patches/series index 3bc38fd..6ee47d0 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -11,3 +11,4 @@ mumps.patch hypre.patch nocleanup.patch umfpack.patch +allow-keys-starting-with-double-dash.patch