[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] bugfix auto-props

From: Martin Furter <mf_at_rola.ch>
Date: 2003-10-08 03:23:57 CEST

On Tue, 7 Oct 2003, Julian Foad wrote:

> Philip Martin wrote:
> > julianfoad@tigris.org writes:
> >
> >>Modified:
> >> trunk/build.conf
> >> trunk/subversion/clients/cmdline/cl.h
> >> trunk/subversion/clients/cmdline/main.c
> >> trunk/subversion/include/svn_config.h
> >> trunk/subversion/libsvn_client/add.c
> >
> > You didn't fix this warning
> >
> > ../svn/subversion/libsvn_client/add.c: In function `auto_props_enumerator':
> > ../svn/subversion/libsvn_client/add.c:89: warning: declaration of `value' shadows a parameter
> > ../svn/subversion/libsvn_client/add.c:68: warning: shadowed declaration is here
> > ../svn/subversion/libsvn_client/add.c:99: warning: assignment discards qualifiers from pointer target type
>
> Ah - I didn't see them scroll by. Fixed those, though not very
> elegantly (with a cast), and also one in
> subversion/clients/cmdline/info-cmd.c which was not due to this commit.

I'm sorry about this. I started fixing these compiler errors but was too
slow :(
Btw which compiler do you use ? My gcc 2.95 didn't output these warnings.

In my last mail i mentioned another problem, apr_collapse_spaces removes
all spaces, not only the leading and trailing ones. So here is a patch
which fixes it and adds some more tests.

Martin

Fix a bug in auto-props by replacing apr_collapse_spaces with the new
function trim_string.

* subversion/libsvn_client/add.c

  (trim_string):
    New function.
  (auto_props_enumerator):
    Use trim_string instead of apr_collapse_spaces.

* subversion/tests/clients/cmdline/autoprop_tests.py

  (create_config):
     Added auto-props for space tests.
  (autoprops_test):
     Added tests for prop names and values containing spaces.

Index: subversion/libsvn_client/add.c
===================================================================
--- subversion/libsvn_client/add.c (revision 7337)
+++ subversion/libsvn_client/add.c (working copy)
@@ -23,6 +23,7 @@
 /*** Includes. ***/
 
 #include <string.h>
+#include <apr_lib.h> /* for apr_isspace() */
 #include <apr_fnmatch.h>
 #include "svn_wc.h"
 #include "svn_client.h"
@@ -59,6 +60,26 @@
   apr_pool_t *pool;
 } auto_props_baton_t;
 
+/* inplace remove leading and trailing white space from a C string */
+static void
+trim_string (char **pstr)
+{
+ char *str = *pstr;
+ int i;
+
+ while (apr_isspace (*str))
+ str++;
+ *pstr = str;
+ i = strlen (str);
+ if (i > 0)
+ {
+ do {
+ --i;
+ } while (apr_isspace (str[i]));
+ str[i+1] = '\0';
+ }
+}
+
 /* For one auto-props config entry (NAME, VALUE), if the filename pattern
    NAME matches BATON->filename then add the properties listed in VALUE
    into BATON->properties. BATON must point to an auto_props_baton_t.
@@ -94,16 +115,16 @@
         {
           *this_value = 0;
           this_value++;
- apr_collapse_spaces (this_value, this_value);
+ trim_string (&this_value);
         }
- else
- {
- this_value = (char *)"";
- }
- apr_collapse_spaces (property, property);
+ trim_string (&property);
       len = strlen (property);
       if (len > 0)
         {
+ /* if this_value is NULL set it to an empty string */
+ if (!this_value)
+ this_value = property + len;
+
           apr_hash_set (autoprops->properties, property, len,
this_value);
           if (strcmp (property, SVN_PROP_MIME_TYPE) == 0)
             autoprops->mimetype = this_value;
Index: subversion/tests/clients/cmdline/autoprop_tests.py
===================================================================
--- subversion/tests/clients/cmdline/autoprop_tests.py (revision 7337)
+++ subversion/tests/clients/cmdline/autoprop_tests.py (working copy)
@@ -91,6 +91,7 @@
   fd.write('*.jpg = jpgfile=ja\n')
   fd.write('fubar* = tarfile=si\n')
   fd.write('foobar.lha = lhafile=da;lzhfile=niet\n')
+ fd.write('spacetest = a b c = d e f ; g h i = j k l ; m n o = ; = p
\n')
   fd.write('* = auto=oui\n')
   fd.write('\n')
   fd.close()
@@ -180,6 +181,8 @@
   create_test_file(files_dir, filenames[len(filenames)-1])
   filenames = filenames + ['foobar.lha']
   create_test_file(files_dir, filenames[len(filenames)-1])
+ filenames = filenames + ['spacetest']
+ create_test_file(files_dir, filenames[len(filenames)-1])
 
   if len(subdir) == 0:
     # add/import the files
@@ -224,6 +227,12 @@
     check_prop('auto', filename, ['oui'])
     check_prop('lhafile', filename, ['da'])
     check_prop('lzhfile', filename, ['niet'])
+ filename = os.path.join(files_wc_dir, 'spacetest' )
+ check_proplist(filename,['a b c', 'g h i', 'm n o', 'auto'])
+ check_prop('auto', filename, ['oui'])
+ check_prop('a b c', filename, ['d e f'])
+ check_prop('g h i', filename, ['j k l'])
+ check_prop('m n o', filename, [])
   else:
     filename = os.path.join(files_wc_dir, 'foo.h' )
     check_proplist(filename,[])

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Oct 8 03:29:11 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.