Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 279819 Details for
Bug 374899
sys-apps/openrc: service_get_value strips \n and returns only one line
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
rc_getline-rc_service_get_value.patch (DRAFT)
rc_getline-rc_service_get_value.patch (text/plain), 1.23 KB, created by
Christian Ruppert (idl0r)
on 2011-07-12 01:21:47 UTC
(
hide
)
Description:
rc_getline-rc_service_get_value.patch (DRAFT)
Filename:
MIME Type:
Creator:
Christian Ruppert (idl0r)
Created:
2011-07-12 01:21:47 UTC
Size:
1.23 KB
patch
obsolete
>diff --git a/src/librc/librc-misc.c b/src/librc/librc-misc.c >index 7244dee..1e1915b 100644 >--- a/src/librc/librc-misc.c >+++ b/src/librc/librc-misc.c >@@ -70,10 +70,8 @@ rc_getline(char **line, size_t *len, FILE *fp) > if (fgets(p, BUFSIZ, fp) == NULL) > break; > last += strlen(p); >- if (last && (*line)[last - 1] == '\n') { >- (*line)[last - 1] = '\0'; >+ if (last) > break; >- } > } > return last; > } >diff --git a/src/librc/librc.c b/src/librc/librc.c >index a6ff0fe..508567f 100644 >--- a/src/librc/librc.c >+++ b/src/librc/librc.c >@@ -771,15 +771,25 @@ rc_service_value_get(const char *service, const char *option) > char *line = NULL; > size_t len = 0; > char file[PATH_MAX]; >+ char *value = NULL; > > snprintf(file, sizeof(file), RC_SVCDIR "/options/%s/%s", > service, option); > if ((fp = fopen(file, "r"))) { >- rc_getline(&line, &len, fp); >+ while (rc_getline(&line, &len, fp)) { >+ if (value == NULL) { >+ value = (char *)xmalloc((len + 1) * sizeof(char)); >+ strncpy(value, line, (len + 1)); >+ } >+ else { >+ value = (char *)xrealloc(value, ((strlen(value) + len) * sizeof(char))); >+ strncat(value, line, (len + 1)); >+ } >+ } > fclose(fp); > } > >- return line; >+ return value; > } > librc_hidden_def(rc_service_value_get) >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 374899
: 279819