Parcourir la source

Fixed another copy/paste mistake found using a script to search for such mistakes.

mingodad il y a 13 ans
Parent
commit
3b97c79035
2 fichiers modifiés avec 29 ajouts et 1 suppressions
  1. 1 1
      SquiLu-ext/sq_fltk.cpp
  2. 28 0
      SquiLu/samples/test-extensions-copy-paste-error.nut

+ 1 - 1
SquiLu-ext/sq_fltk.cpp

@@ -3752,7 +3752,7 @@ static SQRESULT _fl_globals_fl_height(HSQUIRRELVM v)
     SQ_FUNC_VARS(v);
     if(_top_ > 1){
         SQ_GET_INTEGER(v, 2, font);
-        SQ_GET_INTEGER(v, 2, font_size);
+        SQ_GET_INTEGER(v, 3, font_size);
         sq_pushinteger(v, fl_height(font, font_size));
     }
     else sq_pushinteger(v, fl_height());

+ 28 - 0
SquiLu/samples/test-extensions-copy-paste-error.nut

@@ -0,0 +1,28 @@
+local text = [==[
+    SQ_GET_INTEGER(v, 2, x);
+    SQ_GET_INTEGER(v, 3, y);
+    SQ_GET_INTEGER(v, 4, w);
+    SQ_GET_INTEGER(v, 5, h);
+]==];
+
+local error_re = "(SQ_GET_[^(]+%([^,]+,%s*(%d))[^\n]+%s+SQ_GET_[^(]+%([^,]+,%s*(%d)";
+
+text.gmatch(error_re, function(m1, d1, d2){
+	print(m1, d1,d2);
+	return true;
+});
+
+
+local base_dir = "../../SquiLu-ext";
+foreach(fname in sqfs.dir(base_dir)){
+	if(fname.endswith(".cpp")){
+		print(fname);
+		local fd = file(base_dir + "/" + fname, "r");
+		local fc = fd.read(fd.len());
+		fd.close();
+		fc.gmatch(error_re, function(m1, d1, d2){
+			if(d1 == d2) print(m1, d1,d2);
+			return true;
+		});
+	}
+}