MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / dk_words

Function dk_words

src/pipeline/pass_docker.c:942–985  ·  view source on GitHub ↗

The words of shell text [p, e): split at blanks outside quotes, quotes * and backslash escapes removed (a backslash-newline is a blank). */

Source from the content-addressed store, hash-verified

940/* The words of shell text [p, e): split at blanks outside quotes, quotes
941 * and backslash escapes removed (a backslash-newline is a blank). */
942static int dk_words(dk_t *d, const char *p, const char *e, const char **out, int max) {
943 int n = 0;
944 while (p < e && n < max) {
945 while (p < e && (isspace((unsigned char)*p) ||
946 (*p == '\\' && p + SKIP_ONE < e && p[SKIP_ONE] == '\n'))) {
947 p += *p == '\\' ? PAIR_LEN : SKIP_ONE;
948 }
949 if (p >= e) {
950 break;
951 }
952 char *w = cbm_arena_alloc(d->a, (size_t)(e - p) + SKIP_ONE);
953 if (!w) {
954 return n;
955 }
956 size_t len = 0;
957 char quote = 0;
958 while (p < e && (quote || !isspace((unsigned char)*p))) {
959 char c = *p++;
960 if (quote) {
961 if (c == quote) {
962 quote = 0;
963 } else if (c == '\\' && quote == '"' && p < e &&
964 (*p == '"' || *p == '\\' || *p == '$' || *p == '`')) {
965 w[len++] = *p++;
966 } else {
967 w[len++] = c;
968 }
969 } else if (c == '\'' || c == '"') {
970 quote = c;
971 } else if (c == '\\' && p < e) {
972 if (*p == '\n') {
973 p++;
974 break;
975 }
976 w[len++] = *p++;
977 } else {
978 w[len++] = c;
979 }
980 }
981 w[len] = '\0';
982 out[n++] = w;
983 }
984 return n;
985}
986
987/* `go build` flags that take the next word as their value (go help build). */
988static bool dk_go_value_flag(const char *f) {

Callers 2

dk_runFunction · 0.85
dk_entryFunction · 0.85

Calls 1

cbm_arena_allocFunction · 0.50

Tested by

no test coverage detected