chiark / gitweb /
remove format char string truncation syntax
authorKay Sievers <kay.sievers@vrfy.org>
Tue, 19 May 2009 10:56:17 +0000 (12:56 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Tue, 19 May 2009 10:56:17 +0000 (12:56 +0200)
test/udev-test.pl
udev/udev-event.c
udev/udev.xml

index 788bbeac259de7a9fa59dd65357f6ab073e8272f..b5abe620fb4c159f64c94fc8437fcce9e3165753 100755 (executable)
@@ -281,15 +281,6 @@ EOF
                exp_name        => "Major:8:minor:5:kernelnumber:5:id:0:0:0:0" ,
                rules           => <<EOF
 SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", NAME="Major:%M:minor:%m:kernelnumber:%n:id:%b"
-EOF
-       },
-       {
-               desc            => "test substitution chars (with length limit)",
-               subsys          => "block",
-               devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
-               exp_name        => "M8-m5-n5-b0:0-xAT" ,
-               rules           => <<EOF
-SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", NAME="M%M-m%m-n%n-b%3b-x%2s{vendor}"
 EOF
        },
        {
@@ -354,7 +345,7 @@ SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n test-%b", RESULT=="test-0:0*", NAME="
 EOF
        },
        {
-               desc            => "program with escaped format char (tricky: callout returns format char!)",
+               desc            => "program with escaped format char (callout returns format char!)",
                subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
                exp_name        => "escape-5" ,
@@ -1019,16 +1010,6 @@ EOF
                exp_target      => "ttyACM0",
                rules           => <<EOF
 KERNEL=="ttyACM[0-9]*", NAME="ttyACM%n", SYMLINK+="%s{dev}"
-EOF
-       },
-       {
-               desc            => "symlink %Ns{filename} substitution",
-               subsys          => "tty",
-               devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
-               exp_name        => "166",
-               exp_target      => "ttyACM0",
-               rules           => <<EOF
-KERNEL=="ttyACM[0-9]*", NAME="ttyACM%n", SYMLINK+="%3s{dev}"
 EOF
        },
        {
index 345fb20e22773a15ce28ce31a22c2a0abeb20fd3..03ae352415dde48118b04464ad3d96b74efd1e37 100644 (file)
@@ -77,32 +77,12 @@ static char *get_format_attribute(struct udev *udev, char **str)
        return attr;
 }
 
-/* extract possible format length and move str behind it*/
-static int get_format_len(struct udev *udev, char **str)
-{
-       int num;
-       char *tail;
-
-       if (isdigit(*str[0])) {
-               num = (int) strtoul(*str, &tail, 10);
-               if (num > 0) {
-                       *str = tail;
-                       dbg(udev, "format length=%i\n", num);
-                       return num;
-               } else {
-                       err(udev, "format parsing error '%s'\n", *str);
-               }
-       }
-       return -1;
-}
-
 void udev_event_apply_format(struct udev_event *event, char *string, size_t maxsize)
 {
        struct udev_device *dev = event->dev;
        char temp[UTIL_PATH_SIZE];
        char temp2[UTIL_PATH_SIZE];
        char *head, *tail, *cpos, *attr, *rest;
-       int len;
        int i;
        int count;
        enum subst_type {
@@ -153,7 +133,6 @@ void udev_event_apply_format(struct udev_event *event, char *string, size_t maxs
 
        head = string;
        while (1) {
-               len = -1;
                while (head[0] != '\0') {
                        if (head[0] == '$') {
                                /* substitute named variable */
@@ -188,7 +167,6 @@ void udev_event_apply_format(struct udev_event *event, char *string, size_t maxs
                                }
                                head[0] = '\0';
                                tail = head+1;
-                               len = get_format_len(event->udev, &tail);
                                for (subst = map; subst->name; subst++) {
                                        if (tail[0] == subst->fmt) {
                                                type = subst->type;
@@ -447,11 +425,6 @@ found:
                        err(event->udev, "unknown substitution type=%i\n", type);
                        break;
                }
-               /* possibly truncate to format-char specified length */
-               if (len >= 0 && len < (int)strlen(head)) {
-                       head[len] = '\0';
-                       dbg(event->udev, "truncate to %i chars, subtitution string becomes '%s'\n", len, head);
-               }
                util_strlcat(string, temp, maxsize);
        }
 }
index 084c13bd98cb5d3a6f60719c5d0d1f8083c3c163..cd4884d3b5529d4d98777536d0db3b97ece07e65 100644 (file)
               </listitem>
             </varlistentry>
           </variablelist>
-          <para>The count of characters to be substituted may be limited by specifying
-          the format length value. For example, '%3s{file}' will only
-          insert the first three characters of the sysfs attribute</para>
         </refsect2>
       </refsect1>