[CRIU] [RFC 10/11] Remove \u and \U GNU-isms from sed command

Christopher Covington cov at codeaurora.org
Mon Feb 10 08:49:25 PST 2014


Hi Pavel,

On 02/10/2014 05:40 AM, Pavel Emelyanov wrote:
> On 02/07/2014 09:04 PM, Christopher Covington wrote:
>> This allows building with busybox sed, for example.
> 
> After applying this patch compilation breaks on my box:
> 
>   CC       protobuf-desc.o
> In file included from protobuf-desc.c:97:0:
> protobuf-desc-gen.h: In function ‘cr_pb_init’:
> protobuf-desc-gen.h:1:1: error: pasting "PB_" and "/" does not give a valid preprocessing token
> protobuf-desc-gen.h:1:1: error: ‘PB_’ undeclared (first use in this function)
> protobuf-desc-gen.h:1:1: note: each undeclared identifier is reported only once for each function it appears in
> protobuf-desc-gen.h:1:1: error: ‘bin’ undeclared (first use in this function)
> protobuf-desc-gen.h:1:1: error: expected expression before ‘/’ token
> 
> ...
> 
> This is because the protobuf-desc-get.h contains
> 
> $ head -3 protobuf-desc-gen.h 
> CR_PB_DESC(/bin, /bin, /bin);
> CR_PB_DESC(/boot, /boot, /boot);
> CR_PB_DESC(/cgroup, /cgroup, /cgroup);
> 
> instead of
> 
> $ head -3 protobuf-desc-gen.h 
> CR_PB_DESC(INVENTORY, Inventory, inventory);
> CR_PB_DESC(STATS, Stats, stats);
> CR_PB_DESC(FDINFO, Fdinfo, fdinfo);
> 
>> ---
>>  scripts/protobuf-gen.sh | 19 +++++++++++++++----
>>  1 file changed, 15 insertions(+), 4 deletions(-)
>>
>> diff --git a/scripts/protobuf-gen.sh b/scripts/protobuf-gen.sh
>> index dad8d12..8e4b3c4 100644
>> --- a/scripts/protobuf-gen.sh
>> +++ b/scripts/protobuf-gen.sh
>> @@ -1,7 +1,18 @@
>> +TR="y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
>> +
>>  for x in $(cat include/protobuf-desc.h | \
>> -		sed -n '/PB_AUTOGEN_START/,/PB_AUTOGEN_STOP/p' | \
>> -		fgrep -v 'PB_AUTOGEN_S' | sed -e 's/,.*$//' -e 's/PB_//'); do
>> -	x_la=$(echo $x | tr 'A-Z' 'a-z')
>> -	x_uf=$(echo $x_la | sed -e 's/^./\u&/' -e 's/_./\U&/g' -e 's/_//g')
>> +		sed -n '/PB_AUTOGEN_START/,/PB_AUTOGEN_STOP/{
>> +			/PB_AUTOGET_ST/d;

Sorry, I made a typo when rebasing. This should be PB_AUTOGEN_ST. I'll send
out v2 addressing this.

>> +			s/,.*$//;
>> +			s/\tPB_//;
>> +			p;
>> +		}'); do
>> +	x_la=$(echo $x | sed $TR)
>> +	x_uf=$(echo $x | sed -nr 's/^./&#\\\
>> +/; s/_(.)/\\\
>> +\1#\\\
>> +/g; p' | \
>> +		sed -r "/^[A-Z]#\\\\\$/!{ $TR; }" | \
>> +		sed -r ':loop; N; s/#?\\\n//; t loop')
>>  	echo "CR_PB_DESC($x, $x_uf, $x_la);"
>>  done
>>

Thanks,
Christopher

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by the Linux Foundation.


More information about the CRIU mailing list