From de1aa4c56e86755ed0ac6e96127d8b744115bec1 Mon Sep 17 00:00:00 2001 From: mfranz Date: Wed, 23 Jul 2008 15:43:45 +0000 Subject: [PATCH] finally make printf() globally available --- Nasal/debug.nas | 4 ++-- Nasal/geo.nas | 1 - Nasal/globals.nas | 8 +++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Nasal/debug.nas b/Nasal/debug.nas index 305e7e024..2a1671ba4 100644 --- a/Nasal/debug.nas +++ b/Nasal/debug.nas @@ -327,9 +327,9 @@ var printerror = func(err) { if (!size(err)) return; - print(sprintf("%s at %s line %d", err[0], err[1], err[2])); + printf("%s at %s line %d", err[0], err[1], err[2]); for (var i = 3; i < size(err); i += 2) - print(sprintf(" called from %s line %d", err[i], err[i + 1])); + printf(" called from %s line %d", err[i], err[i + 1]); } diff --git a/Nasal/geo.nas b/Nasal/geo.nas index d72b5c234..d3cda074b 100644 --- a/Nasal/geo.nas +++ b/Nasal/geo.nas @@ -57,7 +57,6 @@ var FT2M = 0.3048; var M2FT = 3.28083989501312335958; -var printf = func { print(call(sprintf, arg)) } var floor = func(v) { v < 0.0 ? -int(-v) - 1 : int(v) } var sin = nil; var cos = nil; diff --git a/Nasal/globals.nas b/Nasal/globals.nas index 7dfe54ae5..fcaa8bc3a 100644 --- a/Nasal/globals.nas +++ b/Nasal/globals.nas @@ -77,7 +77,7 @@ var setlistener = func(node, fun, init = 0, runtime = 1) { }, init, runtime); if(__.log_level <= 2) { var c = caller(1); - print(sprintf("setting listener #%d in %s, line %s", id, c[2], c[3])); + printf("setting listener #%d in %s, line %s", id, c[2], c[3]); } return id; } @@ -107,6 +107,12 @@ var defined = func(sym) { var thisfunc = func caller(1)[1]; +## +# Just what it says it is. +# +var printf = func print(call(sprintf, arg)); + + ## # Print log messages in appropriate --log-level. # Usage: printlog("warn", "...");