diff --git a/fdpp/makefile b/fdpp/makefile index afc8e7ef..4cda933e 100644 --- a/fdpp/makefile +++ b/fdpp/makefile @@ -146,7 +146,7 @@ $(FDPP_CPPOBJS): %.o: $(srcdir)/%.cpp $(PPHDRS) $(srcdir)/makefile $(CXX) $(CXXFLAGS) -o $@ $< $(GEN_CC): %.cc: $(SRC)/%.c makefile - $(srcdir)/parsers/mkfar.sh $< >$@ + $(srcdir)/parsers/mkfar.sh $< | $(srcdir)/parsers/fix_printf.py -I $< -o $@ $(FDPPLIB): $(OBJECTS) $(FDPP_COBJS) $(FDPP_CCOBJS) $(FDPP_CPPOBJS) $(CXX_LD) -o $@ $^ $(LDFLAGS) $(_LDFLAGS) $(LIBS) diff --git a/fdpp/meson.build b/fdpp/meson.build index 38a92fe9..78c836ee 100644 --- a/fdpp/meson.build +++ b/fdpp/meson.build @@ -2,6 +2,7 @@ project('libfdpp', ['c', 'cpp'], default_options: ['cpp_std=c++20'], version: '0.1', meson_version: '>= 1.3.0') MF = meson.current_source_dir() / 'parsers/mkfar.sh' +FP = meson.current_source_dir() / 'parsers/fix_printf.py' PD = meson.current_source_dir() / 'parsers/parse_decls.sh' RA = meson.current_source_dir() / 'run_arg.sh' NS = meson.current_source_dir() / 'num.sh' @@ -68,11 +69,17 @@ CFILES = [ SRC / 'prf.c', SRC / 'share.c'] -ccgen = generator(find_program(MF), - output: '@BASENAME@.cc', +ccgen1 = generator(find_program(MF), + output: '@BASENAME@.cc.int1', arguments: ['@INPUT@'], capture: true) -ccfiles = ccgen.process(CFILES) +ccfiles1 = ccgen1.process(CFILES) + +ccgen2 = generator(find_program(FP), + output: '@BASENAME@', + arguments: ['-i', '@INPUT@', '-O', '@BASENAME@'], + capture: true) +ccfiles = ccgen2.process(ccfiles1) make = find_program(['gmake', 'make']) diff --git a/fdpp/parsers/fix_printf.py b/fdpp/parsers/fix_printf.py new file mode 100755 index 00000000..0cb935c4 --- /dev/null +++ b/fdpp/parsers/fix_printf.py @@ -0,0 +1,300 @@ +#!/usr/bin/python + +import sys +import re + +from os.path import relpath +from pathlib import Path +from textwrap import dedent + + +# Combined transformation configuration map +TRANSFORMS_MAP = { + 'S': { + 'wrapper': 'GET_PTR', + 'replacement': 's' + }, + 'Fs': { + 'wrapper': 'GET_PTR', + 'replacement': 's' + }, + 'P': { + 'wrapper': 'GET_FP32', + 'replacement': None + }, + 'Fp': { + 'wrapper': 'GET_FP32', + 'replacement': 'P', + }, +# Example only +# 'Y': { +# 'wrapper': None, # Leaves the variable exactly as written +# 'replacement': 'p' # Mutates %Y -> %p inside the string literal +# } +} + +FORMAT_INDEX_MAP = { +# Std + 'printf': 0, + 'fprintf': 1, + 'sprintf': 1, + 'snprintf': 2, + +# FreeDOS specific + 'DebugPrintf': 0, + 'HMAInitPrintf': 0, + 'log': 0, + 'tn_printf': 0, + '_printf': 0, + '_fprintf': 1, + '_sprintf': 1, + '_snprintf': 2, + +# FDPP + 'fdloudprintf': 0, +} + +FUNC_PATTERN = re.compile(rf"\b({'|'.join(FORMAT_INDEX_MAP.keys())})\s*\(", re.MULTILINE) + +CLEAN_MSG = f"C source clean up opportunity" + + +def usage(error=None): + """ + Usage: python fix_printf.py (-i|-I) (-o|-O) + -i: Use input.c as input file + -I: Use stdin as input, input.c is the name used in warnings/errors + -o: Use output.c as output file + -O: Use stdout as output, output.c is the name used in warnings/errors + """ + + print(dedent(usage.__doc__), file=sys.stderr) + if error: + print(error, file=sys.stderr) + + +def extract_balanced_args_with_positions(text, start_pos): + """ + Steps through characters starting at an open parenthesis. + Returns a list of tuples containing: (arg_text, global_start_idx, global_end_idx). + Preserves all internal whitespace, tabs, and newlines exactly. + """ + args = [] + current_arg = [] + paren_depth = 0 + in_string = False + escape = False + + arg_start = start_pos + 1 + i = start_pos + + while i < len(text): + char = text[i] + + if in_string: + current_arg.append(char) + if escape: + escape = False + elif char == '\\': + escape = True + elif char == '"': + in_string = False + else: + if char == '"': + in_string = True + current_arg.append(char) + elif char == '(': + paren_depth += 1 + if paren_depth > 1: + current_arg.append(char) + elif char == ')': + paren_depth -= 1 + if paren_depth == 0: + if current_arg or len(args) > 0: + args.append(("".join(current_arg), arg_start, i)) + return i + 1, args + current_arg.append(char) + elif char == ',' and paren_depth == 1: + args.append(("".join(current_arg), arg_start, i)) + current_arg = [] + arg_start = i + 1 + else: + current_arg.append(char) + i += 1 + return -1, [] + + +def process_file(argv): + + def relative(name): + current_dir = Path.cwd().resolve() + full_path = Path(name).resolve() + return relpath(full_path, current_dir) + + input_name = relative(argv[2]) # for any error messages we issue + if argv[1] == '-i': + try: + input_code = Path(argv[2]).read_text(encoding='cp437') + print(f"Reading {input_name}", file=sys.stderr) + except FileNotFoundError: + usage(f"Could not open input file '{input_name}") + sys.exit(2) + elif argv[1] == '-I': + print(f"Reading stdin (named as {input_name})", file=sys.stderr) + sys.stdin.reconfigure(encoding='cp437', newline=None) + input_code = sys.stdin.read() + else: + usage(f"Invalid {argv[1]}") + sys.exit(2) + + output_name = relative(argv[4]) # for any error messages we issue + if argv[3] == '-o': + output_stdout = False + elif argv[3] == '-O': + output_stdout = True + else: + usage(f"Invalid {argv[3]}") + sys.exit(2) + + has_errors = False + modifications = [] + pos = 0 + + while True: + match = FUNC_PATTERN.search(input_code, pos) + if not match: + break + + func_name = match.group(1) + func_start = match.start() + open_paren_pos = match.end() - 1 + + end_pos, args = extract_balanced_args_with_positions(input_code, open_paren_pos) + + if end_pos == -1 or not args: + pos = match.end() + continue + + # Double-parentheses macro unpacking layer + if len(args) == 1 and args[0][0].strip().startswith('(') and args[0][0].strip().endswith(')'): + inner_text_raw, inner_start, inner_end = args[0] + first_paren = inner_text_raw.find('(') + _, inner_args = extract_balanced_args_with_positions(inner_text_raw, first_paren) + if inner_args: + args = [(txt, inner_start + s, inner_start + e) for txt, s, e in inner_args] + + + fmt_index = FORMAT_INDEX_MAP[func_name] + if fmt_index >= len(args): + pos = end_pos + continue + + fmt_arg_text, fmt_start, fmt_end = args[fmt_index] + fmt_arg_stripped = fmt_arg_text.strip() + + if not (fmt_arg_stripped.startswith('"') and fmt_arg_stripped.endswith('"')): + pos = end_pos + continue + + fmt_str = fmt_arg_stripped[1:-1] + + specifier_pattern = re.compile(r'%(?:%|[0-9.+\-*#lhzj]*[a-zA-Z]+)') + specifiers = [t for t in specifier_pattern.findall(fmt_str) if t != '%%'] + vargs = args[fmt_index + 1:] + + updated_fmt_str = fmt_str + format_string_modified = False + + for i, spec in enumerate(specifiers): + if i >= len(vargs): + break + + arg_text, arg_start, arg_end = vargs[i] + arg_stripped = arg_text.strip() + + target_token = next((token for token in TRANSFORMS_MAP if token in spec), None) + + line_no = input_code.count('\n', 0, func_start) + 1 + file_msg = f"[{input_name}:{line_no}/{func_name}]" + + if target_token: + transform_config = TRANSFORMS_MAP[target_token] + wrapper = transform_config['wrapper'] + replacement = transform_config['replacement'] + + # Enforce the strict policy check ONLY if we are actively wrapping an argument + if wrapper is not None: + if '(' in arg_stripped and not re.match(r'^\s*\([^)]+\)\s*[a-zA-Z_]', arg_stripped): + func_msg = f"'%{target_token} / {arg_stripped}'" + # Check if it is already wrapped in the target macro + if arg_stripped.startswith(f"{wrapper}(") and arg_stripped.endswith(')'): + print(f"Info: {file_msg} {CLEAN_MSG}, '{spec}' already applied so could remove the {wrapper}() around '{arg_stripped}'", file=sys.stderr) + + # Clean the format string specifier even if the variable was already wrapped + if replacement is not None: + replaced_spec = spec.replace(target_token, replacement) + updated_fmt_str = updated_fmt_str.replace(spec, replaced_spec, 1) + format_string_modified = True + continue + else: + # It's an unauthorized nested macro, throw a hard build error + print(f"Error: {file_msg} Found restricted macro/function call {func_msg} - Aborting.", file=sys.stderr) + has_errors = True + continue + + # Safe whitespace preservation wrap + leading_spaces = arg_text[:len(arg_text)-len(arg_text.lstrip())] + trailing_spaces = arg_text[len(arg_text.rstrip()):] + wrapped_arg_text = f"{leading_spaces}{wrapper}({arg_stripped}){trailing_spaces}" + modifications.append((arg_start, arg_end, wrapped_arg_text)) + + # Process the string literal replacement rule (e.g. %Y -> %p) + if replacement is not None: + replaced_spec = spec.replace(target_token, replacement) + updated_fmt_str = updated_fmt_str.replace(spec, replaced_spec, 1) + format_string_modified = True + + else: + # C++ism DETECTION PASS: + # The specifier is already a standard format token (%s or %p) + # Check if the developer manually added a C++ wrapper macro + for token, config in TRANSFORMS_MAP.items(): + wrapper = config['wrapper'] + replacement = config['replacement'] + + if wrapper and arg_stripped.startswith(f"{wrapper}(") and arg_stripped.endswith(')'): + print(f"Info: {file_msg} {CLEAN_MSG}, '{spec}' could be replaced with '%{token}' and the {wrapper}() removed around '{arg_stripped}'", file=sys.stderr) + break + + if format_string_modified and not has_errors: + leading_fmt_spaces = fmt_arg_text[:len(fmt_arg_text)-len(fmt_arg_text.lstrip())] + trailing_fmt_spaces = fmt_arg_text[len(fmt_arg_text.rstrip()):] + + new_fmt_arg_text = f'{leading_fmt_spaces}"{updated_fmt_str}"{trailing_fmt_spaces}' + modifications.append((fmt_start, fmt_end, new_fmt_arg_text)) + + pos = end_pos + + if has_errors: + sys.exit(1) + + modifications.sort(key=lambda x: x, reverse=True) + + output_code = list(input_code) + for start, end, new_text in modifications: + output_code[start:end] = list(new_text) + + if output_stdout: + sys.stdout.reconfigure(encoding='utf-8') + with sys.stdout as f: + f.write("".join(output_code)) + else: + with open(output_name, 'w', encoding='utf-8') as f: + f.write("".join(output_code)) + +if __name__ == "__main__": + if len(sys.argv) < 5: + usage("Not enough arguments") + sys.exit(1) + process_file(sys.argv) + diff --git a/kernel/config.c b/kernel/config.c index 43640024..89331c8f 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -358,12 +358,12 @@ void PreConfig(void) #ifdef DEBUG { - DebugPrintf(("SDA located at 0x%P\n", GET_FP32(internal_data))); + DebugPrintf(("SDA located at 0x%P\n", internal_data)); } #endif /* Begin by initializing our system buffers */ #ifdef DEBUG -/* DebugPrintf(("Preliminary %d buffers allocated at 0x%P\n", Config.cfgBuffers, GET_FP32(buffers)));*/ +/* DebugPrintf(("Preliminary %d buffers allocated at 0x%P\n", Config.cfgBuffers, buffers));*/ #endif LoL->_DPBp = (struct dpb FAR *) @@ -404,16 +404,16 @@ void PreConfig(void) } #ifdef DEBUG -/* _printf(" FCB table 0x%P\n",GET_FP32(LoL->FCBp));*/ - DebugPrintf((" sft table 0x%P\n", GET_FP32(LoL->_sfthead))); - DebugPrintf((" CDS table 0x%P\n", GET_FP32(LoL->_CDSp))); - DebugPrintf((" DPB table 0x%P\n", GET_FP32(LoL->_DPBp))); +/* _printf(" FCB table 0x%P\n",LoL->FCBp);*/ + DebugPrintf((" sft table 0x%P\n", LoL->_sfthead)); + DebugPrintf((" CDS table 0x%P\n", LoL->_CDSp)); + DebugPrintf((" DPB table 0x%P\n", LoL->_DPBp)); #endif /* Done. Now initialize the MCB structure */ /* This next line is 8086 and 80x86 real mode specific */ #ifdef DEBUG - DebugPrintf(("Preliminary allocation completed: top at %P\n", GET_FP32(lpTop))); + DebugPrintf(("Preliminary allocation completed: top at %P\n", lpTop)); #endif } @@ -492,7 +492,7 @@ void PostConfig(void) /* Begin by initializing our system buffers */ /* dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); */ #ifdef DEBUG - /* DebugPrintf(("DMA scratchpad allocated at 0x%P\n", GET_FP32(dma_scratch))); */ + /* DebugPrintf(("DMA scratchpad allocated at 0x%P\n", dma_scratch)); */ #endif #if 0 DiskTransferBuffer = KernelAlloc(MAX_SEC_SIZE, 'B', Config.cfgDosDataUmb); @@ -525,10 +525,10 @@ void PostConfig(void) share_init(); #ifdef DEBUG -/* DebugPrintf((" FCB table 0x%P\n",GET_FP32(LoL->FCBp)));*/ - DebugPrintf((" sft table 0x%P\n", GET_FP32(LoL->_sfthead->sftt_next))); - DebugPrintf((" CDS table 0x%P\n", GET_FP32(LoL->_CDSp))); - DebugPrintf((" DPB table 0x%P\n", GET_FP32(LoL->_DPBp))); +/* DebugPrintf((" FCB table 0x%P\n", LoL->FCBp));*/ + DebugPrintf((" sft table 0x%P\n", LoL->_sfthead->sftt_next)); + DebugPrintf((" CDS table 0x%P\n", LoL->_CDSp)); + DebugPrintf((" DPB table 0x%P\n", LoL->_DPBp)); #endif if (Config.cfgStacks) { @@ -537,7 +537,7 @@ void PostConfig(void) Config.cfgStacksHigh); init_stacks(stackBase, Config.cfgStacks, Config.cfgStackSize); - DebugPrintf(("Stacks allocated at %P\n", GET_FP32(stackBase))); + DebugPrintf(("Stacks allocated at %P\n", stackBase)); } #ifdef FDPP #define DOSOBJ_POOL2 256 @@ -992,7 +992,7 @@ VOID DoConfig(int nPass) if (mdsk != NULL) { _printf("MEMDISK version %u.%02u (%lu sectors)\n", mdsk->version, mdsk->version_minor, mdsk->size); - DebugPrintf(("MEMDISK args:{%s}\n", GET_PTR(mdsk->cmdline))); + DebugPrintf(("MEMDISK args:{%S}\n", mdsk->cmdline)); } else { @@ -2534,7 +2534,7 @@ STATIC void config_init_buffers(int wantedbuffers, int high) LoL->_firstbuf = pbuffer; DebugPrintf(("init_buffers (size %zu) at (%P)\n", sizeof(struct buffer), - GET_FP32(LoL->_firstbuf))); + LoL->_firstbuf)); buffers--; pbuffer->b_prev = FP_OFF(pbuffer + buffers); diff --git a/kernel/dosfns.c b/kernel/dosfns.c index b43e2878..9abc0824 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -780,7 +780,7 @@ COUNT DosCloseSft(int sft_idx, BOOL commitonly) */ if (sftp->sft_flags & SFT_FSHARED) { - /* _printf("closing SFT %d = %P\n",sft_idx,GET_FP32(sftp)); */ + /* _printf("closing SFT %d = %P\n",sft_idx, sftp); */ return network_redirector_fp(commitonly ? REM_FLUSH: REM_CLOSE, sftp); } @@ -1061,14 +1061,14 @@ COUNT DosChangeDir(const char FAR * s) return DE_PATHNOTFND; #if defined(CHDIR_DEBUG) - DebugPrintf(("Remote Chdir: n='%Fs' p='%Fs\n", s, PriPathName)); + DebugPrintf(("Remote Chdir: n='%S' p='%S'\n", s, PriPathName)); #endif /* now get fs to change to new */ /* directory */ result = (result & IS_NETWORK ? network_redirector(REM_CHDIR) : dos_cd(PriPathName)); #if defined(CHDIR_DEBUG) - DebugPrintf(("status = %04x, new_path='%Fs'\n", result, cdsd->cdsCurrentPath)); + DebugPrintf(("status = %04x, new_path='%S'\n", result, current_ldt->cdsCurrentPath)); #endif if (result != SUCCESS) return result; @@ -1126,7 +1126,7 @@ COUNT DosFindFirst(UCOUNT attr, const char FAR * name) SAttr = (BYTE) attr; #if defined(FIND_DEBUG) - DebugPrintf(("Remote Find: n='%Fs\n", PriPathName)); + DebugPrintf(("Remote Find: n='%S\n", PriPathName)); #endif dta = &sda_tmp_dm; diff --git a/kernel/dyninit.c b/kernel/dyninit.c index 24ef8236..d0496d84 100644 --- a/kernel/dyninit.c +++ b/kernel/dyninit.c @@ -164,8 +164,7 @@ far_t DynAllocLow(const char *what, unsigned num, unsigned size) void FAR *DynLast(void) { struct HeapS *h = HeapMap[HEAP_LOW]; - DebugPrintf(("dynamic data end at %P\n", - GET_FP32(h->Dynp + h->Allocated))); + DebugPrintf(("dynamic data end at %P\n", h->Dynp + h->Allocated)); return h->Dynp + h->Allocated; } diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 38afe865..7b1d7ab7 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -340,7 +340,7 @@ COUNT dos_findfirst(UCOUNT attr, const char * name) REG f_node_ptr fnp; REG dmatch *dmp = &sda_tmp_dm; -/* _printf("ff %Fs\n", name);*/ +/* _printf("ff %s\n", name);*/ /* The findfirst/findnext calls are probably the worst of the */ /* DOS calls. They must work somewhat on the fly (i.e. - open */ diff --git a/kernel/inithma.c b/kernel/inithma.c index b10513db..3c3b0d6b 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -64,7 +64,7 @@ void int3() STATIC VOID hdump(BYTE FAR * p) { int loop; - HMAInitPrintf(("%P", GET_FP32(p))); + HMAInitPrintf(("%P", p)); for (loop = 0; loop < 16; loop++) HMAInitPrintf(("%02x ", (const char)p[loop])); @@ -261,7 +261,7 @@ void MoveKernel(UWORD NewKernelSegment) } HMAInitPrintf(("HMA moving %P up to %P for %04x bytes\n", - GET_FP32(HMASource), GET_FP32(HMADest), len)); + HMASource, HMADest, len)); NewKernelSegment -= FP_OFF(_HMATextStart) >> 4; for (rp = _HMARelocationTableStart; rp < _HMARelocationTableEnd; rp++) diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 0b5da4d3..6ad37269 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -267,7 +267,7 @@ COUNT truename(__XFAR(const char) src, char FAR *dest, COUNT mode) char FAR *rootPos; char src0; - tn_printf(("truename(%s)\n", GET_PTR(src))); + tn_printf(("truename(%S)\n", src)); /* First, adjust the source pointer */ src = adjust_far(src); @@ -289,7 +289,7 @@ COUNT truename(__XFAR(const char) src, char FAR *dest, COUNT mode) unc_src++; } while (src0); current_ldt = (struct cds FAR *)MK_FP(0xFFFF,0xFFFF); - tn_printf(("Returning path: \"%s\"\n", GET_PTR(dest))); + tn_printf(("Returning path: \"%S\"\n", dest)); /* Flag as network - drive bits are empty but shouldn't get */ /* referenced for network with empty current_ldt. */ return IS_NETWORK; @@ -320,8 +320,8 @@ COUNT truename(__XFAR(const char) src, char FAR *dest, COUNT mode) } fmemcpy(&TempCDS, cdsEntry, sizeof(struct cds)); - tn_printf(("CDS entry: #%u @%P (%u) '%s'\n", result, GET_FP32(cdsEntry), - TempCDS.cdsBackslashOffset, GET_FP32(TempCDS.cdsCurrentPath))); + tn_printf(("CDS entry: #%u @%P (%u) '%S'\n", result, cdsEntry, + TempCDS.cdsBackslashOffset, TempCDS.cdsCurrentPath)); /* is the current_ldt thing necessary for compatibly?? -- 2001/09/03 ska*/ current_ldt = cdsEntry; @@ -338,7 +338,7 @@ COUNT truename(__XFAR(const char) src, char FAR *dest, COUNT mode) { if (!(mode & CDS_MODE_SKIP_PHYSICAL) && QRemote_Fn(dest, src) == SUCCESS && dest[0] != '\0') { - tn_printf(("QRemoteFn() returned: \"%s\"\n", GET_PTR(dest))); + tn_printf(("QRemoteFn() returned: \"%S\"\n", dest)); #ifdef DEBUG_TRUENAME if (fstrlen(dest) >= REMOTE_PATH_MAX) panic("Truename: QRemote_Fn() overflowed output buffer"); @@ -429,7 +429,7 @@ COUNT truename(__XFAR(const char) src, char FAR *dest, COUNT mode) if (!(mode & CDS_MODE_SKIP_PHYSICAL)) { - tn_printf(("SUBSTing from: %s\n", cp)); + tn_printf(("SUBSTing from: %S\n", cp)); /* What to do now: the logical drive letter will be replaced by the hidden portion of the associated path. This is necessary for NETWORK and SUBST drives. For local drives it should not harm. @@ -583,7 +583,7 @@ COUNT truename(__XFAR(const char) src, char FAR *dest, COUNT mode) assumed that the CDS is configured correctly and if it contains lower case letters, it is required so **/ - tn_printf(("Absolute logical path: \"%s\"\n", GET_PTR(dest))); + tn_printf(("Absolute logical path: \"%S\"\n", dest)); /* Now, all the steps 1) .. 7) are fullfilled. Join now */ /* search, if this path is a joined drive */ @@ -617,7 +617,7 @@ COUNT truename(__XFAR(const char) src, char FAR *dest, COUNT mode) result &= ~IS_NETWORK; if (cdsp->cdsFlags & CDSNETWDRV) result |= IS_NETWORK; - tn_printf(("JOINed path: \"%s\"\n", GET_PTR(dest))); + tn_printf(("JOINed path: \"%S\"\n", dest)); return result; } } @@ -637,6 +637,6 @@ COUNT truename(__XFAR(const char) src, char FAR *dest, COUNT mode) else result = 0; /* AL is 00, 2f, 5c, or last-of-TempCDS.cdsCurrentPath? */ } - tn_printf(("Physical path: \"%s\"\n", GET_PTR(dest))); + tn_printf(("Physical path: \"%S\"\n", dest)); return result; } diff --git a/kernel/nls.c b/kernel/nls.c index 9f1f5c05..3d6347be 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -102,7 +102,7 @@ STATIC long muxGo(int subfct, UWORD bp, UWORD cp, UWORD cntry, UWORD bufsize, { long ret; log(("NLS: muxGo(): subfct=%x, cntry=%u, cp=%u, ES:DI=%P\n", - subfct, cntry, cp, GET_FP32(buf))); + subfct, cntry, cp, buf)); ret = call_nls(bp, buf, subfct, cp, cntry, bufsize); log(("NLS: muxGo(): return value = %lx\n", ret)); return ret; @@ -144,7 +144,7 @@ STATIC int muxBufGo(int subfct, int bp, UWORD cp, UWORD cntry, UWORD bufsize, VOID FAR * buf) { log(("NLS: muxBufGo(): subfct=%x, BP=%u, cp=%u, cntry=%u, len=%u, buf=%P\n", - subfct, bp, cp, cntry, bufsize, GET_FP32(buf))); + subfct, bp, cp, cntry, bufsize, buf)); return (WORD)muxGo(subfct, bp, cp, cntry, bufsize, buf); } diff --git a/kernel/task.c b/kernel/task.c index 67c069d8..a36b40c9 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -551,7 +551,7 @@ STATIC COUNT DosComLoader(const char FAR * namep, exec_blk FAR * exp, COUNT mode } #ifdef DEBUG - DebugPrintf(("DosComLoader. Loading '%s' at %04x\n", GET_PTR(namep), mem)); + DebugPrintf(("DosComLoader. Loading '%S' at %04x\n", namep, mem)); #endif /* Now load the executable */ { @@ -748,7 +748,7 @@ STATIC COUNT DosExeLoader(const char FAR * namep, exec_blk FAR * exp, COUNT mode return rc; #ifdef DEBUG - DebugPrintf(("DosExeLoader. Loading '%s' at %04x\n", GET_PTR(namep), mem)); + DebugPrintf(("DosExeLoader. Loading '%S' at %04x\n", namep, mem)); #endif /* memory found large enough - continue processing */ @@ -962,8 +962,7 @@ VOID ASMCFUNC P_0(const struct config FAR *Config) fmemcpy_n(buf, endp, 2); endp[0] = '\n'; endp[1] = '\0'; - _printf("Process 0 starting: %s%s", GET_PTR(Shell), - exb->exec.cmd_line->ctBuffer); + _printf("Process 0 starting: %S%s", Shell, exb->exec.cmd_line->ctBuffer); /* and back */ n_fmemcpy(endp, buf, 2); @@ -977,23 +976,22 @@ VOID ASMCFUNC P_0_exit(unsigned short retcode) if ((retcode & 0xff) == 0 || (retcode >> 8)) { switch (retcode >> 8) { case 0: - _printf("\nShell %s exited, press any key...\n", GET_PTR(Shell)); + _printf("\nShell %S exited, press any key...\n", Shell); break; case 1: - _printf("\nShell %s aborted (^C), press any key...\n", GET_PTR(Shell)); + _printf("\nShell %S aborted (^C), press any key...\n", Shell); break; case 2: - _printf("\nShell %s aborted due to critical error, press any key...\n", GET_PTR(Shell)); + _printf("\nShell %S aborted due to critical error, press any key...\n", Shell); break; case 4: - _printf("\nShell %s aborted by signal %i, press any key...\n", - GET_PTR(Shell), retcode & 0xff); + _printf("\nShell %S aborted by signal %i, press any key...\n", Shell, retcode & 0xff); break; } con_flush_stdin(); read_char_stdin(0); } else { - _printf("\nShell %s exited with code 0x%x\n", GET_PTR(Shell), retcode); + _printf("\nShell %S exited with code 0x%x\n", Shell, retcode); } fdexit(retcode & 0xff); } @@ -1005,7 +1003,7 @@ VOID ASMCFUNC P_0_bad(void) exec_blk FAR *exb = TempExeBlock_p; if (termNoComcom) { - fdloudprintf("Bad or missing Command Interpreter: %s\n", GET_PTR(Shell)); + fdloudprintf("Bad or missing Command Interpreter: %S\n", Shell); fdexit(1); } put_string("Bad or missing Command Interpreter: "); /* failure _or_ exit */