* udev patch for attributes with trailing spaces in the values
@ 2004-01-30 0:14 Mark Eaton
2004-01-31 1:35 ` Kay Sievers
2004-02-17 1:25 ` Darren Salt
0 siblings, 2 replies; 3+ messages in thread
From: Mark Eaton @ 2004-01-30 0:14 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 511 bytes --]
The following patch strips off spaces that are often contained at the end of
SYSFS_ attributes. (ie lots of printers etc do this).
I'm not sure if this should actually be added to udev but I would be curious
to hear peoples thoughts as I find it extremly annoying and pointless to have
to hexdump the sysfs values to check if there are trailing spaces to write
the various rules.
--
Mark Eaton
Senior Software Engineer
VASCO The Authentication Company
+67 3511 5404
+67 (0) 403 384 886
meaton@vasco.com
[-- Attachment #2: spaces.patch --]
[-- Type: text/x-diff, Size: 503 bytes --]
diff -Nru udev-015-orig/namedev.c udev-015/namedev.c
--- udev-015-orig/namedev.c 2004-01-23 09:28:36.000000000 +1000
+++ udev-015/namedev.c 2004-01-30 08:59:10.000000000 +1000
@@ -427,7 +427,10 @@
label_found:
c = tmpattr->value + strlen(tmpattr->value)-1;
if (*c == '\n')
- *c = 0x00;
+ *c-- = 0x00;
+ while (*c == ' ')
+ *c-- = 0x00;
+
dbg("compare attribute '%s' value '%s' with '%s'",
pair->file, tmpattr->value, pair->value);
if (strcmp_pattern(pair->value, tmpattr->value) != 0)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: udev patch for attributes with trailing spaces in the values
2004-01-30 0:14 udev patch for attributes with trailing spaces in the values Mark Eaton
@ 2004-01-31 1:35 ` Kay Sievers
2004-02-17 1:25 ` Darren Salt
1 sibling, 0 replies; 3+ messages in thread
From: Kay Sievers @ 2004-01-31 1:35 UTC (permalink / raw)
To: linux-hotplug
On Fri, Jan 30, 2004 at 10:14:51AM +1000, Mark Eaton wrote:
> The following patch strips off spaces that are often contained at the end of
> SYSFS_ attributes. (ie lots of printers etc do this).
> I'm not sure if this should actually be added to udev but I would be curious
> to hear peoples thoughts as I find it extremly annoying and pointless to have
> to hexdump the sysfs values to check if there are trailing spaces to write
> the various rules.
You may use udevinfo that prints the ready formated attribute for you
or use the pattern matching if you don't want to count the number of
spaces. :)
> diff -Nru udev-015-orig/namedev.c udev-015/namedev.c
> --- udev-015-orig/namedev.c 2004-01-23 09:28:36.000000000 +1000
> +++ udev-015/namedev.c 2004-01-30 08:59:10.000000000 +1000
> @@ -427,7 +427,10 @@
> label_found:
> c = tmpattr->value + strlen(tmpattr->value)-1;
> if (*c = '\n')
> - *c = 0x00;
> + *c-- = 0x00;
Huh, what if the value is only the '\n'?
> + while (*c = ' ')
> + *c-- = 0x00;
thanks,
Kay
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: udev patch for attributes with trailing spaces in the values
2004-01-30 0:14 udev patch for attributes with trailing spaces in the values Mark Eaton
2004-01-31 1:35 ` Kay Sievers
@ 2004-02-17 1:25 ` Darren Salt
1 sibling, 0 replies; 3+ messages in thread
From: Darren Salt @ 2004-02-17 1:25 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 1665 bytes --]
I demand that Kay Sievers may or may not have written...
> On Fri, Jan 30, 2004 at 10:14:51AM +1000, Mark Eaton wrote:
>> The following patch strips off spaces that are often contained at the end
>> of SYSFS_ attributes. (ie lots of printers etc do this). I'm not sure if
>> this should actually be added to udev but I would be curious to hear
>> peoples thoughts as I find it extremly annoying and pointless to have to
>> hexdump the sysfs values to check if there are trailing spaces to write
>> the various rules.
> You may use udevinfo that prints the ready formated attribute for you or
> use the pattern matching if you don't want to count the number of spaces.
> :)
I recently hit this problem when adding a device name (mainly "because I
can") for a CF card reader. Initially, I wasn't aware that there /were/ any
trailing spaces (and I hadn't noticed udevinfo), then I looked again and went
hexdumping...
>> diff -Nru udev-015-orig/namedev.c udev-015/namedev.c
>> --- udev-015-orig/namedev.c 2004-01-23 09:28:36.000000000 +1000
>> +++ udev-015/namedev.c 2004-01-30 08:59:10.000000000 +1000
>> @@ -427,7 +427,10 @@
>> label_found:
>> c = tmpattr->value + strlen(tmpattr->value)-1;
>> if (*c == '\n')
>> - *c = 0x00;
>> + *c-- = 0x00;
> Huh, what if the value is only the '\n'?
Fun and games, of course ;-)
My independently-written version is attached.
--
| Darren Salt | nr. Ashington, | d youmustbejoking,demon,co,uk
| Debian, | Northumberland | s zap,tartarus,org
| RISC OS | Toon Army | @
| When replying, "news"->"ds", "cu"->"co.uk", and validate
By protracting life, we do not deduct one jot from the duration of death.
[-- Attachment #2: trailing-space.patch --]
[-- Type: text/plain, Size: 531 bytes --]
--- udev-016/namedev.c~ 2004-01-31 15:36:18.000000000 +0000
+++ udev-016/namedev.c 2004-02-11 15:09:06.000000000 +0000
@@ -422,9 +422,9 @@
return -ENODEV;
label_found:
- c = tmpattr->value + strlen(tmpattr->value)-1;
- if (*c == '\n')
- *c = 0x00;
+ c = tmpattr->value + strlen(tmpattr->value);
+ while (--c >= tmpattr->value && isspace (*c))
+ *c = 0;
dbg("compare attribute '%s' value '%s' with '%s'",
pair->file, tmpattr->value, pair->value);
if (strcmp_pattern(pair->value, tmpattr->value) != 0)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-02-17 1:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-30 0:14 udev patch for attributes with trailing spaces in the values Mark Eaton
2004-01-31 1:35 ` Kay Sievers
2004-02-17 1:25 ` Darren Salt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).