Skip to content

Commit

Permalink
Remove unused util functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dd86k committed Oct 28, 2024
1 parent 982f7fc commit be58d19
Showing 1 changed file with 0 additions and 55 deletions.
55 changes: 0 additions & 55 deletions src/adbg/utils/strings.d
Original file line number Diff line number Diff line change
Expand Up @@ -50,61 +50,6 @@ extern (D) unittest {
assert(adbg_nstrlenw("hello"w.ptr, 10) == 5);
}

/// Gets the next line out of a file stream.
/// This skips empty lines.
/// The extracted line is null-terminated.
/// Params:
/// bf = Line buffer input.
/// bfsz = Line buffer input size.
/// lnsz = Line length reference.
/// file = File handle.
/// Returns: Line length.
deprecated("FILE is no longer used")
size_t adbg_util_getlinef(char *bf, size_t bfsz, size_t *lnsz, FILE *file) {
if (bf == null || bfsz == 0 || lnsz == null || file == null)
return 0;

import core.stdc.ctype : isprint;

size_t i; /// Line buffer index

// If fgetc return EOF, it is non-printable
for ( ; i < bfsz ; ++i) {
int c = fgetc(file);
if (c == '\n')
break;
if (isprint(c))
bf[i] = cast(char)c;
}

bf[i] = 0;
*lnsz = i;
return i;
}
extern (D) unittest {
import std.stdio : writefln;
import std.file : write, tempDir, remove;
import std.path : buildPath;
import std.string : toStringz;

string tmppath = buildPath(tempDir, "alicedbg_unittest");
write(tmppath, "123\n\nabc");
FILE *fd = fopen(tmppath.toStringz, "r");

char[16] line = void;
size_t linesz = void;
size_t i;
while (adbg_util_getlinef(line.ptr, 16, &linesz, fd)) {
final switch (++i) {
case 1: assert(strncmp(line.ptr, "123", linesz) == 0); break;
case 2: assert(strncmp(line.ptr, "abc", linesz) == 0); break;
}
}

fclose(fd);
remove(tmppath);
}

/// Gets the next line out of a file stream.
/// This skips empty lines.
/// The extracted line is null-terminated.
Expand Down

0 comments on commit be58d19

Please sign in to comment.