Skip to content

Commit 64f18c6

Browse files
committed
remove new line can be hardcoded, since we know where it is
1 parent b103204 commit 64f18c6

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

flang/runtime/command.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -142,31 +142,19 @@ static bool FitsInDescriptor(
142142
kind, terminator, value);
143143
}
144144

145-
void removeNewLine(char *str) {
146-
char *newlinePos = std::strchr(str, '\n');
147-
if (newlinePos) {
148-
*newlinePos = '\0'; // Replace with null terminator
149-
}
150-
}
151-
152145
std::int32_t RTNAME(FDate)(const Descriptor *value, const Descriptor *errmsg) {
153146
FillWithSpaces(*value);
154-
155147
std::time_t current_time;
156148
std::time(&current_time);
157149
std::array<char, 26> str;
158-
// Day Mon dd hh:mm:ss yyyy\n is 26 character,
159-
// e.g. Tue May 26 21:51:03 2015\n\0
150+
// Day Mon dd hh:mm:ss yyyy\n\0 is 26 characters, e.g.
151+
// Tue May 26 21:51:03 2015\n\0
160152

161153
ctime_alloc(str.data(), str.size(), current_time);
162-
removeNewLine(str.data());
163-
std::int64_t stringLen{StringLength(str.data())};
164-
if (stringLen <= 0) {
165-
return ToErrmsg(errmsg, StatMissingArgument);
166-
}
154+
str[24] = '\0'; // remove new line
167155

168156
if (value) {
169-
return CopyToDescriptor(*value, str.data(), stringLen, errmsg);
157+
return CopyToDescriptor(*value, str.data(), 24, errmsg);
170158
}
171159

172160
return StatOk;

0 commit comments

Comments
 (0)