Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libinput
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
89
Issues
89
List
Boards
Labels
Service Desk
Milestones
Merge Requests
12
Merge Requests
12
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
libinput
libinput
Commits
d80bbcb0
Commit
d80bbcb0
authored
Mar 20, 2020
by
Peter Hutterer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: record: drop quotes from os-release information
Signed-off-by:
Peter Hutterer
<
peter.hutterer@who-t.net
>
parent
4d92ea11
Pipeline
#122496
passed with stages
in 28 minutes and 45 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
2 deletions
+67
-2
src/util-strings.h
src/util-strings.h
+26
-0
test/test-utils.c
test/test-utils.c
+39
-0
tools/libinput-record.c
tools/libinput-record.c
+2
-2
No files found.
src/util-strings.h
View file @
d80bbcb0
...
...
@@ -312,3 +312,29 @@ error:
free
(
result
);
return
-
1
;
}
/**
* Strip any of the characters in what from the beginning and end of the
* input string.
*
* @return a newly allocated string with none of "what" at the beginning or
* end of string
*/
static
inline
char
*
strstrip
(
const
char
*
input
,
const
char
*
what
)
{
char
*
str
,
*
last
;
str
=
safe_strdup
(
&
input
[
strspn
(
input
,
what
)]);
last
=
str
;
for
(
char
*
c
=
str
;
*
c
!=
'\0'
;
c
++
)
{
if
(
!
strchr
(
what
,
*
c
))
last
=
c
+
1
;
}
*
last
=
'\0'
;
return
str
;
}
test/test-utils.c
View file @
d80bbcb0
...
...
@@ -1033,6 +1033,44 @@ START_TEST(strjoin_test)
}
END_TEST
START_TEST
(
strstrip_test
)
{
struct
strstrip_test
{
const
char
*
string
;
const
char
*
expected
;
const
char
*
what
;
}
tests
[]
=
{
{
"foo"
,
"foo"
,
"1234"
},
{
"
\"
bar
\"
"
,
"bar"
,
"
\"
"
},
{
"'bar'"
,
"bar"
,
"'"
},
{
"
\"
bar
\"
"
,
"
\"
bar
\"
"
,
"'"
},
{
"'bar'"
,
"'bar'"
,
"
\"
"
},
{
"
\"
bar
\"
"
,
"bar"
,
"
\"
"
},
{
"
\"\"
"
,
""
,
"
\"
"
},
{
"
\"
foo
\"
bar
\"
"
,
"foo
\"
bar"
,
"
\"
"
},
{
"
\"
'foo
\"
bar
\"
"
,
"foo
\"
bar"
,
"
\"
'"
},
{
"abcfooabcbarbca"
,
"fooabcbar"
,
"abc"
},
{
"xxxxfoo"
,
"foo"
,
"x"
},
{
"fooyyyy"
,
"foo"
,
"y"
},
{
"xxxxfooyyyy"
,
"foo"
,
"xy"
},
{
"x xfooy y"
,
" xfooy "
,
"xy"
},
{
" foo
\n
"
,
"foo"
,
"
\n
"
},
{
""
,
""
,
"abc"
},
{
""
,
""
,
""
},
{
NULL
,
NULL
,
NULL
}
};
struct
strstrip_test
*
t
=
tests
;
while
(
t
->
string
)
{
char
*
str
;
str
=
strstrip
(
t
->
string
,
t
->
what
);
ck_assert_str_eq
(
str
,
t
->
expected
);
free
(
str
);
t
++
;
}
}
END_TEST
START_TEST
(
list_test_insert
)
{
struct
list_test
{
...
...
@@ -1138,6 +1176,7 @@ litest_utils_suite(void)
tcase_add_test
(
tc
,
strsplit_test
);
tcase_add_test
(
tc
,
kvsplit_double_test
);
tcase_add_test
(
tc
,
strjoin_test
);
tcase_add_test
(
tc
,
strstrip_test
);
tcase_add_test
(
tc
,
time_conversion
);
tcase_add_test
(
tc
,
list_test_insert
);
...
...
tools/libinput-record.c
View file @
d80bbcb0
...
...
@@ -1447,9 +1447,9 @@ print_system_header(struct record_context *ctx)
osrstr
[
strlen
(
osrstr
)
-
1
]
=
'\0'
;
/* linebreak */
if
(
!
distro
&&
strneq
(
osrstr
,
"ID="
,
3
))
distro
=
s
afe_strdup
(
&
osrstr
[
3
]
);
distro
=
s
trstrip
(
&
osrstr
[
3
],
"
\"
'"
);
else
if
(
!
version
&&
strneq
(
osrstr
,
"VERSION_ID="
,
11
))
version
=
s
afe_strdup
(
&
osrstr
[
11
]
);
version
=
s
trstrip
(
&
osrstr
[
11
],
"
\"
'"
);
if
(
distro
&&
version
)
{
iprintf
(
ctx
,
"os:
\"
%s:%s
\"\n
"
,
distro
,
version
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment