Skip to content

Commit 5e92101

Browse files
author
x02lucpo
committed
removed a bug in remove_first_and_last_char
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1845 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 0501b7c commit 5e92101

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Compiler/runtime/systemimpl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ RML_BEGIN_LABEL(System__remove_5ffirst_5fand_5flast_5fchar)
173173
int i;
174174
if(length > 1)
175175
{
176-
res=malloc(length-2);
177-
for(i = 1; i < length - 1; ++i)
178-
res[i-1] = str[i];
176+
res=malloc(length-1);
177+
strncpy(res,str + 1,length-2);
178+
179179
res[length-2] = '\0';
180180
}
181181
rmlA0 = (void*) mk_scon(res);

Compiler/winruntime/systemimpl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ RML_BEGIN_LABEL(System__remove_5ffirst_5fand_5flast_5fchar)
160160
int i;
161161
if(length > 1)
162162
{
163-
res=malloc(length-2);
164-
for(i = 1; i < length - 1; ++i)
165-
res[i-1] = str[i];
166-
res[length-2] = '\0';
163+
res=malloc(length-1);
164+
strncpy(res,str + 1,length-2);
165+
166+
res[length-1] = '\0';
167167
}
168168
rmlA0 = (void*) mk_scon(res);
169169
/* adrpo added 2004-10-29 */

0 commit comments

Comments
 (0)