meshlab.patch 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191
  1. diff -rupN -x .git autoclone/meshlab_repo-src/CMakeLists.txt meshlab_repo_patch/CMakeLists.txt
  2. --- autoclone/meshlab_repo-src/CMakeLists.txt 2024-12-06 18:01:10.831623800 -0800
  3. +++ meshlab_repo_patch/CMakeLists.txt 2024-12-06 18:15:09.647799500 -0800
  4. @@ -16,4 +16,6 @@ option(MESHLAB_USE_DEFAULT_BUILD_AND_INS
  5. option(MESHLAB_IS_NIGHTLY_VERSION "Nightly version of meshlab will be used instead of ML_VERSION" OFF)
  6. -add_subdirectory(src)
  7. \ No newline at end of file
  8. +# Disable meshlab project to avoid breaking assimp build (for converting VMRL (.wrl/.x3dv) files to
  9. +# .xml format, just need to compile two source files)
  10. +#add_subdirectory(src)
  11. diff -rupN -x .git autoclone/meshlab_repo-src/src/meshlabplugins/io_x3d/vrml/Parser.cpp meshlab_repo_patch/src/meshlabplugins/io_x3d/vrml/Parser.cpp
  12. --- autoclone/meshlab_repo-src/src/meshlabplugins/io_x3d/vrml/Parser.cpp 2024-12-06 18:01:12.268963700 -0800
  13. +++ meshlab_repo_patch/src/meshlabplugins/io_x3d/vrml/Parser.cpp 2024-12-06 14:19:26.138842300 -0800
  14. @@ -32,11 +32,11 @@
  15. *****************************************************************************/
  16. +#include <vector>
  17. #include <wchar.h>
  18. #include "Parser.h"
  19. #include "Scanner.h"
  20. -
  21. namespace VrmlTranslator {
  22. @@ -95,9 +95,11 @@ bool Parser::WeakSeparator(int n, int sy
  23. }
  24. void Parser::VrmlTranslator() {
  25. - QDomElement root = doc->createElement("X3D");
  26. - QDomElement scene = doc->createElement("Scene");
  27. - root.appendChild(scene);
  28. +// QDomElement root = doc->createElement("X3D");
  29. + pugi::xml_node root = doc->append_child("X3D");
  30. +// QDomElement scene = doc->createElement("Scene");
  31. +// root.appendChild(scene);
  32. + pugi::xml_node scene = root.append_child("Scene");
  33. InitX3dNode();
  34. if (la->kind == 7) {
  35. HeaderStatement();
  36. @@ -108,7 +110,7 @@ void Parser::VrmlTranslator() {
  37. ComponentStatements();
  38. MetaStatements();
  39. Statements(scene);
  40. - doc->appendChild(root);
  41. +// doc->appendChild(root);
  42. }
  43. void Parser::HeaderStatement() {
  44. @@ -147,7 +149,7 @@ void Parser::MetaStatements() {
  45. }
  46. }
  47. -void Parser::Statements(QDomElement& parent) {
  48. +void Parser::Statements(pugi::xml_node& parent) {
  49. while (StartOf(1)) {
  50. Statement(parent);
  51. }
  52. @@ -173,16 +175,16 @@ void Parser::ComponentSupportLevel() {
  53. }
  54. void Parser::ExportStatement() {
  55. - QString str;
  56. + std::string str;
  57. Expect(14);
  58. NodeNameId(str);
  59. Expect(15);
  60. ExportedNodeNameId();
  61. }
  62. -void Parser::NodeNameId(QString& str) {
  63. +void Parser::NodeNameId(std::string& str) {
  64. Expect(1);
  65. - str = QString(coco_string_create_char(t->val));
  66. + str = std::string(coco_string_create_char(t->val));
  67. }
  68. void Parser::ExportedNodeNameId() {
  69. @@ -190,7 +192,7 @@ void Parser::ExportedNodeNameId() {
  70. }
  71. void Parser::ImportStatement() {
  72. - QString str;
  73. + std::string str;
  74. Expect(16);
  75. InlineNodeNameId();
  76. Expect(17);
  77. @@ -217,7 +219,7 @@ void Parser::Metavalue() {
  78. Expect(4);
  79. }
  80. -void Parser::Statement(QDomElement& parent) {
  81. +void Parser::Statement(pugi::xml_node& parent) {
  82. if (StartOf(2)) {
  83. NodeStatement(parent);
  84. } else if (la->kind == 16) {
  85. @@ -231,8 +233,8 @@ void Parser::Statement(QDomElement& pare
  86. } else SynErr(87);
  87. }
  88. -void Parser::NodeStatement(QDomElement& parent) {
  89. - QString tagName, attrValue;
  90. +void Parser::NodeStatement(pugi::xml_node& parent) {
  91. + std::string tagName, attrValue;
  92. if (la->kind == 1 || la->kind == 38) {
  93. Node(parent, tagName, "");
  94. } else if (la->kind == 19) {
  95. @@ -242,17 +244,19 @@ void Parser::NodeStatement(QDomElement&
  96. } else if (la->kind == 20) {
  97. Get();
  98. NodeNameId(attrValue);
  99. - std::map<QString, QString>::const_iterator iter = defNode.find(attrValue);
  100. + std::map<std::string, std::string>::const_iterator iter = defNode.find(attrValue);
  101. if(iter != defNode.end())
  102. {
  103. - QDomElement node = doc->createElement(iter->second);
  104. - node.setAttribute("USE", attrValue);
  105. - parent.appendChild(node);
  106. +// QDomElement node = doc->createElement(iter->second);
  107. + pugi::xml_node node = parent.append_child((iter->second).c_str());
  108. +// node.setAttribute("USE", attrValue);
  109. + node.append_attribute("USE") = attrValue.c_str();
  110. +// parent.appendChild(node);
  111. }
  112. } else SynErr(88);
  113. }
  114. -void Parser::ProtoStatement(QDomElement& parent) {
  115. +void Parser::ProtoStatement(pugi::xml_node& parent) {
  116. if (la->kind == 21) {
  117. Proto(parent);
  118. } else if (la->kind == 34) {
  119. @@ -261,7 +265,7 @@ void Parser::ProtoStatement(QDomElement&
  120. }
  121. void Parser::RouteStatement() {
  122. - QString str;
  123. + std::string str;
  124. Expect(35);
  125. NodeNameId(str);
  126. Expect(17);
  127. @@ -272,22 +276,27 @@ void Parser::RouteStatement() {
  128. InputOnlyId(str);
  129. }
  130. -void Parser::Node(QDomElement& parent, QString& tagName, const QString defValue) {
  131. - bool flag = false; QDomElement node;
  132. +void Parser::Node(pugi::xml_node& parent, std::string& tagName, const std::string defValue) {
  133. + bool flag = false; pugi::xml_node node;
  134. if (la->kind == 1) {
  135. NodeTypeId(tagName);
  136. - std::set<QString>::const_iterator iter = proto.find(tagName);
  137. + std::set<std::string>::const_iterator iter = proto.find(tagName);
  138. if (iter != proto.end())
  139. {
  140. - node = doc->createElement("ProtoInstance");
  141. - node.setAttribute("name", tagName);
  142. +// node = doc->createElement("ProtoInstance");
  143. + node = parent.append_child("ProtoInstance");
  144. +// node.setAttribute("name", tagName);
  145. + node.append_attribute("name") = tagName.c_str();
  146. flag = true;
  147. }
  148. - else
  149. - node = doc->createElement(tagName);
  150. + else {
  151. +// node = doc->createElement(tagName);
  152. + node = parent.append_child(tagName.c_str());
  153. + }
  154. if (defValue != "")
  155. {
  156. - node.setAttribute("DEF", defValue);
  157. +// node.setAttribute("DEF", defValue);
  158. + node.append_attribute("DEF") = defValue.c_str();
  159. defNode[defValue] = tagName;
  160. }
  161. Expect(24);
  162. @@ -298,13 +307,14 @@ void Parser::Node(QDomElement& parent, Q
  163. Expect(24);
  164. ScriptBody();
  165. Expect(25);
  166. - node = doc->createElement("Script");
  167. +// node = doc->createElement("Script");
  168. + node = parent.append_child("Script");
  169. } else SynErr(90);
  170. - parent.appendChild(node);
  171. +// parent.appendChild(node);
  172. }
  173. -void Parser::RootNodeStatement(QDomElement& parent) {
  174. - QString tagName, attrValue;
  175. +void Parser::RootNodeStatement(pugi::xml_node& parent) {
  176. + std::string tagName, attrValue;
  177. if (la->kind == 1 || la->kind == 38) {
  178. Node(parent, tagName, "");
  179. } else if (la->kind == 19) {
  180. @@ -314,70 +324,82 @@ void Parser::RootNodeStatement(QDomEleme
  181. } else SynErr(91);
  182. }
  183. -void Parser::Proto(QDomElement& parent) {
  184. - QString name; QDomElement node;
  185. +void Parser::Proto(pugi::xml_node& parent) {
  186. +// QString name; QDomElement node;
  187. + std::string name; pugi::xml_node node;
  188. Expect(21);
  189. NodeTypeId(name);
  190. - node = doc->createElement("ProtoDeclare");
  191. - node.setAttribute("name", name);
  192. +// node = doc->createElement("ProtoDeclare");
  193. + node = parent.append_child("ProtoDeclare");
  194. +// node.setAttribute("name", name);
  195. + node.append_attribute("name") = name.c_str();
  196. proto.insert(name);
  197. Expect(22);
  198. - QDomElement interf = doc->createElement("ProtoInterface");
  199. +// QDomElement interf = doc->createElement("ProtoInterface");
  200. + pugi::xml_node interf = node.append_child("ProtoInterface");
  201. InterfaceDeclarations(interf);
  202. - node.appendChild(interf);
  203. +// node.appendChild(interf);
  204. Expect(23);
  205. Expect(24);
  206. - QDomElement body = doc->createElement("ProtoBody");
  207. +// QDomElement body = doc->createElement("ProtoBody");
  208. + pugi::xml_node body = node.append_child("ProtoBody");
  209. ProtoBody(body);
  210. - node.appendChild(body);
  211. +// node.appendChild(body);
  212. Expect(25);
  213. - parent.appendChild(node);
  214. +// parent.appendChild(node);
  215. }
  216. -void Parser::Externproto(QDomElement& parent) {
  217. - QString name, url;
  218. - QDomElement node = doc->createElement("ExternProtoDeclare");
  219. +void Parser::Externproto(pugi::xml_node& parent) {
  220. +// QString name, url;
  221. + std::string name, url;
  222. +// QDomElement node = doc->createElement("ExternProtoDeclare");
  223. + pugi::xml_node node = doc->append_child("ExternProtoDeclare");
  224. Expect(34);
  225. NodeTypeId(name);
  226. Expect(22);
  227. ExternInterfaceDeclarations(node);
  228. Expect(23);
  229. URLList(url);
  230. - std::set<QString>::const_iterator iter = x3dNode.find(name);
  231. + std::set<std::string>::const_iterator iter = x3dNode.find(name);
  232. if (iter == x3dNode.end())
  233. {
  234. - node.setAttribute("name", name);
  235. - node.setAttribute("url", url);
  236. - parent.appendChild(node);
  237. +// node.setAttribute("name", name);
  238. + node.append_attribute("name") = name.c_str();
  239. +// node.setAttribute("url", url);
  240. + node.append_attribute("url") = url.c_str();
  241. +// parent.appendChild(node);
  242. + parent.append_copy(node);
  243. proto.insert(name);
  244. }
  245. + doc->remove_child(node);
  246. }
  247. -void Parser::ProtoStatements(QDomElement& parent) {
  248. +void Parser::ProtoStatements(pugi::xml_node& parent) {
  249. while (la->kind == 21 || la->kind == 34) {
  250. ProtoStatement(parent);
  251. }
  252. }
  253. -void Parser::NodeTypeId(QString& str) {
  254. +void Parser::NodeTypeId(std::string& str) {
  255. Expect(1);
  256. - str = QString(coco_string_create_char(t->val));
  257. + str = std::string(coco_string_create_char(t->val));
  258. }
  259. -void Parser::InterfaceDeclarations(QDomElement& parent) {
  260. +void Parser::InterfaceDeclarations(pugi::xml_node& parent) {
  261. while (StartOf(3)) {
  262. InterfaceDeclaration(parent);
  263. }
  264. }
  265. -void Parser::ProtoBody(QDomElement& parent) {
  266. +void Parser::ProtoBody(pugi::xml_node& parent) {
  267. ProtoStatements(parent);
  268. RootNodeStatement(parent);
  269. Statements(parent);
  270. }
  271. -void Parser::InterfaceDeclaration(QDomElement& parent) {
  272. - QString name, type, val; QDomElement node;
  273. +void Parser::InterfaceDeclaration(pugi::xml_node& parent) {
  274. +// QString name, type, val; QDomElement node;
  275. + std::string name, type, val; pugi::xml_node node;
  276. if (StartOf(4)) {
  277. RestrictedInterfaceDeclaration(parent);
  278. } else if (la->kind == 32 || la->kind == 33) {
  279. @@ -388,18 +410,23 @@ void Parser::InterfaceDeclaration(QDomEl
  280. }
  281. FieldType(type);
  282. FieldId(name);
  283. + node = parent.append_child("field");
  284. FieldValue(node, "value", false);
  285. - node = doc->createElement("field");
  286. - node.setAttribute("name", name);
  287. - node.setAttribute("type", type);
  288. - node.setAttribute("accessType", "inputOutput");
  289. - parent.appendChild(node);
  290. +// node = doc->createElement("field");
  291. +// node.setAttribute("name", name);
  292. + node.append_attribute("name") = name.c_str();
  293. +// node.setAttribute("type", type);
  294. + node.append_attribute("type") = type.c_str();
  295. +// node.setAttribute("accessType", "inputOutput");
  296. + node.append_attribute("accessType") = "inputOutput";
  297. +// parent.appendChild(node);
  298. } else SynErr(92);
  299. }
  300. -void Parser::RestrictedInterfaceDeclaration(QDomElement& parent) {
  301. - QString name; QString type; QString val;
  302. - QDomElement node = doc->createElement("field");
  303. +void Parser::RestrictedInterfaceDeclaration(pugi::xml_node& parent) {
  304. + std::string name; std::string type; std::string val;
  305. +// QDomElement node = doc->createElement("field");
  306. + pugi::xml_node node = parent.append_child("field");
  307. if (la->kind == 26 || la->kind == 27) {
  308. if (la->kind == 26) {
  309. Get();
  310. @@ -408,7 +435,8 @@ void Parser::RestrictedInterfaceDeclarat
  311. }
  312. FieldType(type);
  313. InputOnlyId(name);
  314. - node.setAttribute("accessType", "inputOnly");
  315. +// node.setAttribute("accessType", "inputOnly");
  316. + node.append_attribute("accessType") = "inputOnly";
  317. } else if (la->kind == 28 || la->kind == 29) {
  318. if (la->kind == 28) {
  319. Get();
  320. @@ -417,7 +445,8 @@ void Parser::RestrictedInterfaceDeclarat
  321. }
  322. FieldType(type);
  323. OutputOnlyId(name);
  324. - node.setAttribute("accessType", "outputOnly");
  325. +// node.setAttribute("accessType", "outputOnly");
  326. + node.append_attribute("accessType") = "outputOnly";
  327. } else if (la->kind == 30 || la->kind == 31) {
  328. if (la->kind == 30) {
  329. Get();
  330. @@ -427,14 +456,17 @@ void Parser::RestrictedInterfaceDeclarat
  331. FieldType(type);
  332. InitializeOnlyId(name);
  333. FieldValue(node, "value", false);
  334. - node.setAttribute("accessType", "initializeOnly");
  335. +// node.setAttribute("accessType", "initializeOnly");
  336. + node.append_attribute("accessType") = "initializeOnly";
  337. } else SynErr(93);
  338. - node.setAttribute("name", name);
  339. - node.setAttribute("type", type);
  340. - parent.appendChild(node);
  341. +// node.setAttribute("name", name);
  342. + node.append_attribute("name") = name.c_str();
  343. +// node.setAttribute("type", type);
  344. + node.append_attribute("type") = type.c_str();
  345. +// parent.appendChild(node);
  346. }
  347. -void Parser::FieldType(QString& str) {
  348. +void Parser::FieldType(std::string& str) {
  349. switch (la->kind) {
  350. case 40: {
  351. Get();
  352. @@ -606,25 +638,25 @@ void Parser::FieldType(QString& str) {
  353. }
  354. default: SynErr(94); break;
  355. }
  356. - str = QString(coco_string_create_char(t->val));
  357. + str = std::string(coco_string_create_char(t->val));
  358. }
  359. -void Parser::InputOnlyId(QString& str) {
  360. +void Parser::InputOnlyId(std::string& str) {
  361. Expect(1);
  362. - str = QString(coco_string_create_char(t->val));
  363. + str = std::string(coco_string_create_char(t->val));
  364. }
  365. -void Parser::OutputOnlyId(QString& str) {
  366. +void Parser::OutputOnlyId(std::string& str) {
  367. Expect(1);
  368. - str = QString(coco_string_create_char(t->val));
  369. + str = std::string(coco_string_create_char(t->val));
  370. }
  371. -void Parser::InitializeOnlyId(QString& str) {
  372. +void Parser::InitializeOnlyId(std::string& str) {
  373. Expect(1);
  374. - str = QString(coco_string_create_char(t->val));
  375. + str = std::string(coco_string_create_char(t->val));
  376. }
  377. -void Parser::FieldValue(QDomElement& parent, QString fieldName, bool flag) {
  378. +void Parser::FieldValue(pugi::xml_node& parent, std::string fieldName, bool flag) {
  379. if (StartOf(5)) {
  380. SingleValue(parent, fieldName, flag);
  381. } else if (la->kind == 22) {
  382. @@ -632,21 +664,21 @@ void Parser::FieldValue(QDomElement& par
  383. } else SynErr(95);
  384. }
  385. -void Parser::FieldId(QString& str) {
  386. +void Parser::FieldId(std::string& str) {
  387. Expect(1);
  388. - str = QString(coco_string_create_char(t->val));
  389. + str = std::string(coco_string_create_char(t->val));
  390. }
  391. -void Parser::ExternInterfaceDeclarations(QDomElement& parent) {
  392. +void Parser::ExternInterfaceDeclarations(pugi::xml_node& parent) {
  393. while (StartOf(3)) {
  394. ExternInterfaceDeclaration(parent);
  395. }
  396. }
  397. -void Parser::URLList(QString& url) {
  398. +void Parser::URLList(std::string& url) {
  399. if (la->kind == 4) {
  400. Get();
  401. - url = QString(coco_string_create_char(t->val));
  402. + url = std::string(coco_string_create_char(t->val));
  403. } else if (la->kind == 22) {
  404. Get();
  405. while (la->kind == 4) {
  406. @@ -660,9 +692,10 @@ void Parser::URLList(QString& url) {
  407. } else SynErr(96);
  408. }
  409. -void Parser::ExternInterfaceDeclaration(QDomElement& parent) {
  410. - QString type, name;
  411. - QDomElement node = doc->createElement("field");
  412. +void Parser::ExternInterfaceDeclaration(pugi::xml_node& parent) {
  413. + std::string type, name;
  414. +// QDomElement node = doc->createElement("field");
  415. + pugi::xml_node node = parent.append_child("field");
  416. if (la->kind == 26 || la->kind == 27) {
  417. if (la->kind == 26) {
  418. Get();
  419. @@ -671,7 +704,8 @@ void Parser::ExternInterfaceDeclaration(
  420. }
  421. FieldType(type);
  422. InputOnlyId(name);
  423. - node.setAttribute("accessType", "inputOnly");
  424. +// node.setAttribute("accessType", "inputOnly");
  425. + node.append_attribute("accessType") = "inputOnly";
  426. } else if (la->kind == 28 || la->kind == 29) {
  427. if (la->kind == 28) {
  428. Get();
  429. @@ -680,7 +714,8 @@ void Parser::ExternInterfaceDeclaration(
  430. }
  431. FieldType(type);
  432. OutputOnlyId(name);
  433. - node.setAttribute("accessType", "outputOnly");
  434. +// node.setAttribute("accessType", "outputOnly");
  435. + node.append_attribute("accessType") = "outputOnly";
  436. } else if (la->kind == 30 || la->kind == 31) {
  437. if (la->kind == 30) {
  438. Get();
  439. @@ -689,7 +724,8 @@ void Parser::ExternInterfaceDeclaration(
  440. }
  441. FieldType(type);
  442. InitializeOnlyId(name);
  443. - node.setAttribute("accessType", "initializeOnly");
  444. +// node.setAttribute("accessType", "initializeOnly");
  445. + node.append_attribute("accessType") = "initializeOnly";
  446. } else if (la->kind == 32 || la->kind == 33) {
  447. if (la->kind == 32) {
  448. Get();
  449. @@ -698,14 +734,17 @@ void Parser::ExternInterfaceDeclaration(
  450. }
  451. FieldType(type);
  452. FieldId(name);
  453. - node.setAttribute("accessType", "inputOutput");
  454. +// node.setAttribute("accessType", "inputOutput");
  455. + node.append_attribute("accessType") = "inputOutput";
  456. } else SynErr(97);
  457. - node.setAttribute("name" , name);
  458. - node.setAttribute("type", type);
  459. - parent.appendChild(node);
  460. +// node.setAttribute("name" , name);
  461. + node.append_attribute("name") = name.c_str();
  462. +// node.setAttribute("type", type);
  463. + node.append_attribute("type") = type.c_str();
  464. +// parent.appendChild(node);
  465. }
  466. -void Parser::NodeBody(QDomElement& parent, bool flag) {
  467. +void Parser::NodeBody(pugi::xml_node& parent, bool flag) {
  468. while (StartOf(6)) {
  469. NodeBodyElement(parent, flag);
  470. }
  471. @@ -717,24 +756,29 @@ void Parser::ScriptBody() {
  472. }
  473. }
  474. -void Parser::NodeBodyElement(QDomElement& parent, bool flag) {
  475. - QString idName, idProto; QDomElement node;
  476. +void Parser::NodeBodyElement(pugi::xml_node& parent, bool flag) {
  477. +// QString idName, idProto; QDomElement node;
  478. + std::string idName, idProto; pugi::xml_node node;
  479. if (la->kind == 1) {
  480. Get();
  481. - idName = QString(coco_string_create_char(t->val));
  482. + idName = std::string(coco_string_create_char(t->val));
  483. if (StartOf(8)) {
  484. FieldValue(parent, idName, flag);
  485. } else if (la->kind == 39) {
  486. Get();
  487. Expect(1);
  488. - idProto = QString(coco_string_create_char(t->val));
  489. - node = doc->createElement("IS");
  490. - QDomElement connect = doc->createElement("connect");
  491. - connect.setAttribute("nodeField", idName);
  492. - connect.setAttribute("protoField", idProto);
  493. - node.appendChild(connect);
  494. - parent.appendChild(node);
  495. -
  496. + idProto = std::string(coco_string_create_char(t->val));
  497. +// node = doc->createElement("IS");
  498. + node = parent.append_child("IS");
  499. +// QDomElement connect = doc->createElement("connect");
  500. + pugi::xml_node connect = node.append_child("connect");
  501. +// connect.setAttribute("nodeField", idName);
  502. + connect.append_attribute("nodeField") = idName.c_str();
  503. +// connect.setAttribute("protoField", idProto);
  504. + connect.append_attribute("protoField") = idProto.c_str();
  505. +// node.appendChild(connect);
  506. +// parent.appendChild(node);
  507. +
  508. } else SynErr(98);
  509. } else if (la->kind == 35) {
  510. RouteStatement();
  511. @@ -744,7 +788,7 @@ void Parser::NodeBodyElement(QDomElement
  512. }
  513. void Parser::ScriptBodyElement() {
  514. - QString str; QDomElement elem;
  515. + std::string str; pugi::xml_node elem;
  516. if (StartOf(6)) {
  517. NodeBodyElement(elem, false);
  518. } else if (la->kind == 26 || la->kind == 27) {
  519. @@ -798,17 +842,21 @@ void Parser::ScriptBodyElement() {
  520. } else SynErr(101);
  521. }
  522. -void Parser::InputOutputId(QString& str) {
  523. +void Parser::InputOutputId(std::string& str) {
  524. Expect(1);
  525. - str = QString(coco_string_create_char(t->val));
  526. + str = std::string(coco_string_create_char(t->val));
  527. }
  528. -void Parser::SingleValue(QDomElement& parent, QString fieldName, bool flag) {
  529. - QString value; QDomElement tmpParent = doc->createElement("tmp");
  530. +void Parser::SingleValue(pugi::xml_node& parent, std::string fieldName, bool flag) {
  531. +// QString value; QDomElement tmpParent = doc->createElement("tmp");
  532. + std::string value; pugi::xml_node tmpParent = doc->append_child("tmpParent");
  533. if (StartOf(9)) {
  534. if (la->kind == 4) {
  535. Get();
  536. - value.append(coco_string_create_char(t->val)); value.remove("\"");
  537. + value.append(coco_string_create_char(t->val)); //value.remove("\"");
  538. + // TODO: modify quotation removal; below violates const-correctness:
  539. + // error: cannot convert ‘std::__cxx11::basic_string<char>::iterator’ to ‘const char*’
  540. +// value.erase(std::remove(value.begin(), value.end(), '"'), value.end());
  541. } else if (la->kind == 2 || la->kind == 3) {
  542. if (la->kind == 2) {
  543. Get();
  544. @@ -839,29 +887,41 @@ void Parser::SingleValue(QDomElement& pa
  545. }
  546. if (flag)
  547. {
  548. - QDomElement node = doc->createElement("fieldValue");
  549. - node.setAttribute("name", fieldName);
  550. - node.setAttribute("value", value);
  551. - parent.appendChild(node);
  552. - }
  553. - else
  554. - parent.setAttribute(fieldName, value);
  555. +// QDomElement node = doc->createElement("fieldValue");
  556. + pugi::xml_node node = parent.append_child("fieldValue");
  557. +// node.setAttribute("name", fieldName);
  558. + node.append_attribute("name") = fieldName.c_str();
  559. +// node.setAttribute("value", value);
  560. + node.append_attribute("value") = value.c_str();
  561. +// parent.appendChild(node);
  562. + }
  563. + else {
  564. +// parent.setAttribute(fieldName, value);
  565. + parent.append_attribute(fieldName.c_str()) = value.c_str();
  566. + }
  567. } else if (StartOf(2)) {
  568. NodeStatement(tmpParent);
  569. if (flag)
  570. {
  571. - QDomElement tmp = doc->createElement("fieldValue");
  572. - tmp.setAttribute("name", fieldName);
  573. - tmp.appendChild(tmpParent.firstChildElement());
  574. - parent.appendChild(tmp);
  575. - }
  576. - else
  577. - parent.appendChild(tmpParent.firstChildElement());
  578. +// QDomElement tmp = doc->createElement("fieldValue");
  579. + pugi::xml_node tmp = parent.append_child("fieldValue");
  580. +// tmp.setAttribute("name", fieldName);
  581. + tmp.append_attribute("name") = fieldName.c_str();
  582. +// tmp.appendChild(tmpParent.firstChildElement());
  583. + tmp.insert_child_before(pugi::node_element, tmpParent.first_child());
  584. +// parent.appendChild(tmp);
  585. + }
  586. + else {
  587. +// parent.appendChild(tmpParent.firstChildElement());
  588. + parent.append_copy(tmpParent.first_child());
  589. + }
  590. } else SynErr(102);
  591. + doc->remove_child(tmpParent);
  592. }
  593. -void Parser::MultiValue(QDomElement& parent, QString fieldName, bool flag) {
  594. - QString value; QDomElement tmpParent = doc->createElement("tmp");
  595. +void Parser::MultiValue(pugi::xml_node& parent, std::string fieldName, bool flag) {
  596. +// QString value; QDomElement tmpParent = doc->createElement("tmp");
  597. + std::string value; pugi::xml_node tmpParent = doc->append_child("tmpParent");
  598. Expect(22);
  599. if (StartOf(10)) {
  600. if (la->kind == 2 || la->kind == 3) {
  601. @@ -873,14 +933,19 @@ void Parser::MultiValue(QDomElement& par
  602. }
  603. if (flag)
  604. {
  605. - QDomElement tmp = doc->createElement("fieldValue");
  606. - tmp.setAttribute("name", fieldName);
  607. - tmp.setAttribute("value", value);
  608. - parent.appendChild(tmp);
  609. - }
  610. - else
  611. - parent.setAttribute(fieldName, value);
  612. -
  613. +// QDomElement tmp = doc->createElement("fieldValue");
  614. + pugi::xml_node tmp = parent.append_child("fieldValue");
  615. +// tmp.setAttribute("name", fieldName);
  616. + tmp.append_attribute("name") = fieldName.c_str();
  617. +// tmp.setAttribute("value", value);
  618. + tmp.append_attribute("value") = value.c_str();
  619. +// parent.appendChild(tmp);
  620. + }
  621. + else {
  622. +// parent.setAttribute(fieldName, value);
  623. + parent.append_attribute(fieldName.c_str()) = value.c_str();
  624. + }
  625. +
  626. } else if (StartOf(11)) {
  627. while (StartOf(2)) {
  628. NodeStatement(tmpParent);
  629. @@ -888,28 +953,41 @@ void Parser::MultiValue(QDomElement& par
  630. Get();
  631. }
  632. }
  633. - QDomElement child;
  634. - QDomNodeList list = tmpParent.childNodes();
  635. - QDomElement field = doc->createElement("field");
  636. - field.setAttribute("name", fieldName);
  637. - int i = 0;
  638. +// QDomElement child;
  639. + pugi::xml_node child;
  640. +// QDomNodeList list = tmpParent.childNodes();
  641. + std::vector<pugi::xml_node> list;
  642. + for (auto item : tmpParent.children()) {
  643. + list.push_back(item);
  644. + }
  645. +// QDomElement field = doc->createElement("field");
  646. + pugi::xml_node field = parent.append_child("field");
  647. +// field.setAttribute("name", fieldName);
  648. + field.append_attribute("name") = fieldName.c_str();
  649. + unsigned int i = 0;
  650. while(i < list.size())
  651. {
  652. - child = list.at(i).toElement();
  653. - if (flag)
  654. - field.appendChild(child.cloneNode());
  655. - else
  656. - parent.appendChild(child.cloneNode());
  657. + child = list.at(i);//.toElement();
  658. + if (flag) {
  659. +// field.appendChild(child.cloneNode());
  660. + field.append_copy(child);
  661. + } else {
  662. +// parent.appendChild(child.cloneNode());
  663. + parent.append_copy(child);
  664. + }
  665. i++;
  666. }
  667. - if (flag)
  668. - parent.appendChild(field);
  669. -
  670. + if (flag) {
  671. +// parent.appendChild(field);
  672. + } else {
  673. + parent.remove_child(field);
  674. + }
  675. } else SynErr(103);
  676. Expect(23);
  677. + doc->remove_child(tmpParent);
  678. }
  679. -void Parser::MultiNumber(QString& value) {
  680. +void Parser::MultiNumber(std::string& value) {
  681. if (la->kind == 2) {
  682. Get();
  683. } else if (la->kind == 3) {
  684. @@ -932,7 +1010,7 @@ void Parser::MultiNumber(QString& value)
  685. }
  686. }
  687. -void Parser::MultiString(QString& value) {
  688. +void Parser::MultiString(std::string& value) {
  689. Expect(4);
  690. value.append(coco_string_create_char(t->val));
  691. if (la->kind == 37) {
  692. @@ -947,7 +1025,7 @@ void Parser::MultiString(QString& value)
  693. }
  694. }
  695. -void Parser::MultiBool(QString& value) {
  696. +void Parser::MultiBool(std::string& value) {
  697. if (la->kind == 82) {
  698. Get();
  699. } else if (la->kind == 84) {
  700. @@ -1173,7 +1251,7 @@ void Errors::Warning(const wchar_t *s) {
  701. }
  702. void Errors::Exception(const wchar_t* s) {
  703. - wprintf(L"%ls", s);
  704. + wprintf(L"%ls", s);
  705. exit(1);
  706. }
  707. */
  708. diff -rupN -x .git autoclone/meshlab_repo-src/src/meshlabplugins/io_x3d/vrml/Parser.h meshlab_repo_patch/src/meshlabplugins/io_x3d/vrml/Parser.h
  709. --- autoclone/meshlab_repo-src/src/meshlabplugins/io_x3d/vrml/Parser.h 2024-12-06 18:01:12.268963700 -0800
  710. +++ meshlab_repo_patch/src/meshlabplugins/io_x3d/vrml/Parser.h 2024-12-06 18:48:17.891284300 -0800
  711. @@ -35,9 +35,10 @@
  712. #if !defined(VRML_PARSER_H__)
  713. #define VRML_PARSER_H__
  714. -#include <QtXml>
  715. +#include "contrib/pugixml/src/pugixml.hpp"
  716. +#include <map>
  717. #include <set>
  718. -
  719. +#include <string>
  720. #include "Scanner.h"
  721. @@ -48,7 +49,7 @@ class Errors {
  722. public:
  723. int count; // number of errors detected
  724. wchar_t* stringError;
  725. -
  726. +
  727. Errors();
  728. ~Errors();
  729. void SynErr(int line, int col, int n);
  730. @@ -90,14 +91,15 @@ public:
  731. Token *t; // last recognized token
  732. Token *la; // lookahead token
  733. -QDomDocument *doc;
  734. -
  735. - std::map<QString, QString> defNode;
  736. -
  737. - std::set<QString> proto;
  738. -
  739. - std::set<QString> x3dNode;
  740. -
  741. + pugi::xml_document doc_;
  742. + pugi::xml_document *doc = &doc_; // IrrXMLReader* createIrrXMLReader(const char* filename);
  743. +
  744. + std::map<std::string, std::string> defNode;
  745. +
  746. + std::set<std::string> proto;
  747. +
  748. + std::set<std::string> x3dNode;
  749. +
  750. void InitX3dNode()
  751. {
  752. x3dNode.insert("Arc2D"); x3dNode.insert("ArcClose2D"); x3dNode.insert("BallJoint");
  753. @@ -116,7 +118,7 @@ QDomDocument *doc;
  754. x3dNode.insert("EspduTransform"); x3dNode.insert("ExplosionEmitter");
  755. x3dNode.insert("FillProperties"); x3dNode.insert("FloatVertexAttribute");
  756. x3dNode.insert("FogCoordinate"); x3dNode.insert(" GeneratedCubeMapTexture");
  757. - x3dNode.insert("GeoCoordinate"); x3dNode.insert("GeoElevationGrid"); x3dNode.insert("GeoLocation");
  758. + x3dNode.insert("GeoCoordinate"); x3dNode.insert("GeoElevationGrid"); x3dNode.insert("GeoLocation");
  759. x3dNode.insert("GeoLOD"); x3dNode.insert("GeoMetadata"); x3dNode.insert("GeoOrigin");
  760. x3dNode.insert("GeoPositionInterpolator"); x3dNode.insert("GeoProximitySensor");
  761. x3dNode.insert("GeoTouchSensor"); x3dNode.insert("GeoViewpoint"); x3dNode.insert("GravityPhysicsModel");
  762. @@ -128,7 +130,7 @@ QDomDocument *doc;
  763. x3dNode.insert("Layer"); x3dNode.insert("LayerSet"); x3dNode.insert("Layout");
  764. x3dNode.insert("LayoutGroup"); x3dNode.insert("LayoutLayer"); x3dNode.insert("LinePicker");
  765. x3dNode.insert("LineProperties"); x3dNode.insert("LineSet"); x3dNode.insert("LoadSensor");
  766. - x3dNode.insert("LocalFog"); x3dNode.insert("Material"); x3dNode.insert("Matrix3VertexAttribute");
  767. + x3dNode.insert("LocalFog"); x3dNode.insert("Material"); x3dNode.insert("Matrix3VertexAttribute");
  768. x3dNode.insert("Matrix4VertexAttribute"); x3dNode.insert("MetadataDouble");
  769. x3dNode.insert("MetadataFloat"); x3dNode.insert("MetadataInteger"); x3dNode.insert("MetadataSet");
  770. x3dNode.insert("MetadataString"); x3dNode.insert("MotorJoint"); x3dNode.insert("MultiTexture");
  771. @@ -162,7 +164,7 @@ QDomDocument *doc;
  772. x3dNode.insert(" Viewpoint"); x3dNode.insert("ViewpointGroup"); x3dNode.insert("VolumeEmitter");
  773. x3dNode.insert("VolumePicker"); x3dNode.insert("WindPhysicsModel"); x3dNode.insert("Cylinder"); x3dNode.insert("Sphere");
  774. }
  775. -
  776. +
  777. Parser(Scanner *scanner);
  778. @@ -174,52 +176,52 @@ QDomDocument *doc;
  779. void ProfileStatement();
  780. void ComponentStatements();
  781. void MetaStatements();
  782. - void Statements(QDomElement& parent);
  783. + void Statements(pugi::xml_node& parent);
  784. void ProfileNameId();
  785. void ComponentStatement();
  786. void ComponentNameId();
  787. void ComponentSupportLevel();
  788. void ExportStatement();
  789. - void NodeNameId(QString& str);
  790. + void NodeNameId(std::string& str);
  791. void ExportedNodeNameId();
  792. void ImportStatement();
  793. void InlineNodeNameId();
  794. void MetaStatement();
  795. void Metakey();
  796. void Metavalue();
  797. - void Statement(QDomElement& parent);
  798. - void NodeStatement(QDomElement& parent);
  799. - void ProtoStatement(QDomElement& parent);
  800. + void Statement(pugi::xml_node& parent);
  801. + void NodeStatement(pugi::xml_node& parent);
  802. + void ProtoStatement(pugi::xml_node& parent);
  803. void RouteStatement();
  804. - void Node(QDomElement& parent, QString& tagName, const QString defValue);
  805. - void RootNodeStatement(QDomElement& parent);
  806. - void Proto(QDomElement& parent);
  807. - void Externproto(QDomElement& parent);
  808. - void ProtoStatements(QDomElement& parent);
  809. - void NodeTypeId(QString& str);
  810. - void InterfaceDeclarations(QDomElement& parent);
  811. - void ProtoBody(QDomElement& parent);
  812. - void InterfaceDeclaration(QDomElement& parent);
  813. - void RestrictedInterfaceDeclaration(QDomElement& parent);
  814. - void FieldType(QString& str);
  815. - void InputOnlyId(QString& str);
  816. - void OutputOnlyId(QString& str);
  817. - void InitializeOnlyId(QString& str);
  818. - void FieldValue(QDomElement& parent, QString fieldName, bool flag);
  819. - void FieldId(QString& str);
  820. - void ExternInterfaceDeclarations(QDomElement& parent);
  821. - void URLList(QString& url);
  822. - void ExternInterfaceDeclaration(QDomElement& parent);
  823. - void NodeBody(QDomElement& parent, bool flag);
  824. + void Node(pugi::xml_node& parent, std::string& tagName, const std::string defValue);
  825. + void RootNodeStatement(pugi::xml_node& parent);
  826. + void Proto(pugi::xml_node& parent);
  827. + void Externproto(pugi::xml_node& parent);
  828. + void ProtoStatements(pugi::xml_node& parent);
  829. + void NodeTypeId(std::string& str);
  830. + void InterfaceDeclarations(pugi::xml_node& parent);
  831. + void ProtoBody(pugi::xml_node& parent);
  832. + void InterfaceDeclaration(pugi::xml_node& parent);
  833. + void RestrictedInterfaceDeclaration(pugi::xml_node& parent);
  834. + void FieldType(std::string& str);
  835. + void InputOnlyId(std::string& str);
  836. + void OutputOnlyId(std::string& str);
  837. + void InitializeOnlyId(std::string& str);
  838. + void FieldValue(pugi::xml_node& parent, std::string fieldName, bool flag);
  839. + void FieldId(std::string& str);
  840. + void ExternInterfaceDeclarations(pugi::xml_node& parent);
  841. + void URLList(std::string& url);
  842. + void ExternInterfaceDeclaration(pugi::xml_node& parent);
  843. + void NodeBody(pugi::xml_node& parent, bool flag);
  844. void ScriptBody();
  845. - void NodeBodyElement(QDomElement& parent, bool flag);
  846. + void NodeBodyElement(pugi::xml_node& parent, bool flag);
  847. void ScriptBodyElement();
  848. - void InputOutputId(QString& str);
  849. - void SingleValue(QDomElement& parent, QString fieldName, bool flag);
  850. - void MultiValue(QDomElement& parent, QString fieldName, bool flag);
  851. - void MultiNumber(QString& value);
  852. - void MultiString(QString& value);
  853. - void MultiBool(QString& value);
  854. + void InputOutputId(std::string& str);
  855. + void SingleValue(pugi::xml_node& parent, std::string fieldName, bool flag);
  856. + void MultiValue(pugi::xml_node& parent, std::string fieldName, bool flag);
  857. + void MultiNumber(std::string& value);
  858. + void MultiString(std::string& value);
  859. + void MultiBool(std::string& value);
  860. void Parse();
  861. diff -rupN -x .git autoclone/meshlab_repo-src/src/meshlabplugins/io_x3d/vrml/Scanner.cpp meshlab_repo_patch/src/meshlabplugins/io_x3d/vrml/Scanner.cpp
  862. --- autoclone/meshlab_repo-src/src/meshlabplugins/io_x3d/vrml/Scanner.cpp 2024-12-06 18:01:12.268963700 -0800
  863. +++ meshlab_repo_patch/src/meshlabplugins/io_x3d/vrml/Scanner.cpp 2024-12-06 14:21:47.920443100 -0800
  864. @@ -39,7 +39,7 @@
  865. wchar_t* coco_string_create(const wchar_t* value) {
  866. wchar_t* data;
  867. - int len = 0;
  868. + size_t len = 0;
  869. if (value) { len = wcslen(value); }
  870. data = new wchar_t[len + 1];
  871. wcsncpy(data, value, len);
  872. @@ -63,7 +63,7 @@ wchar_t* coco_string_create_upper(const
  873. if (!data) { return NULL; }
  874. int dataLen = 0;
  875. - if (data) { dataLen = wcslen(data); }
  876. + if (data) { dataLen = static_cast<int>(wcslen(data)); }
  877. wchar_t *newData = new wchar_t[dataLen + 1];
  878. @@ -80,7 +80,7 @@ wchar_t* coco_string_create_upper(const
  879. wchar_t* coco_string_create_lower(const wchar_t* data) {
  880. if (!data) { return NULL; }
  881. - int dataLen = wcslen(data);
  882. + int dataLen = static_cast<int>(wcslen(data));
  883. return coco_string_create_lower(data, 0, dataLen);
  884. }
  885. @@ -102,11 +102,11 @@ wchar_t* coco_string_create_lower(const
  886. wchar_t* coco_string_create_append(const wchar_t* data1, const wchar_t* data2) {
  887. wchar_t* data;
  888. - int data1Len = 0;
  889. - int data2Len = 0;
  890. + size_t data1Len = 0;
  891. + size_t data2Len = 0;
  892. if (data1) { data1Len = wcslen(data1); }
  893. - if (data2) {data2Len = wcslen(data2); }
  894. + if (data2) { data2Len = wcslen(data2); }
  895. data = new wchar_t[data1Len + data2Len + 1];
  896. @@ -133,13 +133,13 @@ void coco_string_delete(wchar_t* &data)
  897. }
  898. int coco_string_length(const wchar_t* data) {
  899. - if (data) { return wcslen(data); }
  900. + if (data) { return static_cast<int>(wcslen(data)); }
  901. return 0;
  902. }
  903. bool coco_string_endswith(const wchar_t* data, const wchar_t *end) {
  904. - int dataLen = wcslen(data);
  905. - int endLen = wcslen(end);
  906. + size_t dataLen = wcslen(data);
  907. + size_t endLen = wcslen(end);
  908. return (endLen <= dataLen) && (wcscmp(data + dataLen - endLen, end) == 0);
  909. }
  910. @@ -186,8 +186,8 @@ int coco_string_hash(const wchar_t *data
  911. // string handling, ascii character
  912. wchar_t* coco_string_create(const char* value) {
  913. - int len = 0;
  914. - if (value) { len = strlen(value); }
  915. + int len = 0;
  916. + if (value) { len = static_cast<int>(strlen(value)); }
  917. wchar_t* data = new wchar_t[len + 1];
  918. for (int i = 0; i < len; ++i) { data[i] = (wchar_t) value[i]; }
  919. data[len] = 0;
  920. @@ -240,7 +240,7 @@ Buffer::Buffer(FILE* s, bool isUserStrea
  921. fileLen = bufLen = bufStart = 0;
  922. }
  923. bufCapacity = (bufLen>0) ? bufLen : MIN_BUFFER_LENGTH;
  924. - buf = new unsigned char[bufCapacity];
  925. + buf = new unsigned char[bufCapacity];
  926. if (fileLen > 0) SetPos(0); // setup buffer to position 0 (start)
  927. else bufPos = 0; // index 0 is already after the file, thus Pos = 0 is invalid
  928. if (bufLen == fileLen && CanSeek()) Close();
  929. @@ -270,7 +270,7 @@ Buffer::Buffer(const unsigned char* buf,
  930. }
  931. Buffer::~Buffer() {
  932. - Close();
  933. + Close();
  934. if (buf != NULL) {
  935. delete [] buf;
  936. buf = NULL;
  937. @@ -306,12 +306,12 @@ int Buffer::Peek() {
  938. wchar_t* Buffer::GetString(int beg, int end) {
  939. int len = end - beg;
  940. - wchar_t *buf = new wchar_t[len];
  941. + wchar_t *retBuf = new wchar_t[len];
  942. int oldPos = GetPos();
  943. SetPos(beg);
  944. - for (int i = 0; i < len; ++i) buf[i] = (wchar_t) Read();
  945. + for (int i = 0; i < len; ++i) retBuf[i] = (wchar_t) Read();
  946. SetPos(oldPos);
  947. - return buf;
  948. + return retBuf;
  949. }
  950. int Buffer::GetPos() {
  951. @@ -329,16 +329,16 @@ void Buffer::SetPos(int value) {
  952. if ((value < 0) || (value > fileLen)) {
  953. char msg[50];
  954. - sprintf(msg, "Buffer out of bounds access, position: %d", value);
  955. + snprintf(msg, 50, "Buffer out of bounds access, position: %d", value);
  956. throw msg;
  957. -
  958. +
  959. }
  960. if ((value >= bufStart) && (value < (bufStart + bufLen))) { // already in buffer
  961. bufPos = value - bufStart;
  962. } else if (stream != NULL) { // must be swapped in
  963. fseek(stream, value, SEEK_SET);
  964. - bufLen = fread(buf, sizeof(unsigned char), bufCapacity, stream);
  965. + bufLen = static_cast<int>(fread(buf, sizeof(unsigned char), bufCapacity, stream));
  966. bufStart = value; bufPos = 0;
  967. } else {
  968. bufPos = fileLen - bufStart; // make Pos return fileLen
  969. @@ -362,7 +362,7 @@ int Buffer::ReadNextStreamChunk() {
  970. buf = newBuf;
  971. free = bufLen;
  972. }
  973. - int read = fread(buf + bufLen, sizeof(unsigned char), free, stream);
  974. + int read = static_cast<int>(fread(buf + bufLen, sizeof(unsigned char), free, stream));
  975. if (read > 0) {
  976. fileLen = bufLen = (bufLen + read);
  977. return read;
  978. @@ -416,7 +416,7 @@ Scanner::Scanner(const wchar_t* fileName
  979. char *chFileName = coco_string_create_char(fileName);
  980. if ((stream = fopen(chFileName, "rb")) == NULL) {
  981. char msg[50];
  982. - sprintf(msg, "Can not open file: %s", chFileName);
  983. + snprintf(msg, 50, "Can not open file: %s", chFileName);
  984. coco_string_delete(chFileName);
  985. throw msg;
  986. }
  987. @@ -554,7 +554,7 @@ void Scanner::Init() {
  988. heapEnd = (void**) (((char*) heap) + HEAP_BLOCK_SIZE);
  989. *heapEnd = 0;
  990. heapTop = heap;
  991. - if (sizeof(Token) > HEAP_BLOCK_SIZE) {
  992. + if constexpr (sizeof(Token) > HEAP_BLOCK_SIZE) {
  993. throw "Too small HEAP_BLOCK_SIZE";
  994. }
  995. @@ -637,18 +637,18 @@ void Scanner::CreateHeapBlock() {
  996. }
  997. Token* Scanner::CreateToken() {
  998. - Token *t;
  999. + Token *tkn;
  1000. if (((char*) heapTop + (int) sizeof(Token)) >= (char*) heapEnd) {
  1001. CreateHeapBlock();
  1002. }
  1003. - t = (Token*) heapTop;
  1004. + tkn = (Token*) heapTop;
  1005. heapTop = (void*) ((char*) heapTop + sizeof(Token));
  1006. - t->val = NULL;
  1007. - t->next = NULL;
  1008. - return t;
  1009. + tkn->val = NULL;
  1010. + tkn->next = NULL;
  1011. + return tkn;
  1012. }
  1013. -void Scanner::AppendVal(Token *t) {
  1014. +void Scanner::AppendVal(Token *tkn) {
  1015. int reqMem = (tlen + 1) * sizeof(wchar_t);
  1016. if (((char*) heapTop + reqMem) >= (char*) heapEnd) {
  1017. if (reqMem > HEAP_BLOCK_SIZE) {
  1018. @@ -656,11 +656,11 @@ void Scanner::AppendVal(Token *t) {
  1019. }
  1020. CreateHeapBlock();
  1021. }
  1022. - t->val = (wchar_t*) heapTop;
  1023. + tkn->val = (wchar_t*) heapTop;
  1024. heapTop = (void*) ((char*) heapTop + reqMem);
  1025. - wcsncpy(t->val, tval, tlen);
  1026. - t->val[tlen] = L'\0';
  1027. + wcsncpy(tkn->val, tval, tlen);
  1028. + tkn->val[tlen] = L'\0';
  1029. }
  1030. Token* Scanner::NextToken() {
  1031. diff -rupN -x .git autoclone/meshlab_repo-src/src/meshlabplugins/io_x3d/vrml/Scanner.h meshlab_repo_patch/src/meshlabplugins/io_x3d/vrml/Scanner.h
  1032. --- autoclone/meshlab_repo-src/src/meshlabplugins/io_x3d/vrml/Scanner.h 2024-12-06 18:01:12.268963700 -0800
  1033. +++ meshlab_repo_patch/src/meshlabplugins/io_x3d/vrml/Scanner.h 2024-12-06 14:21:59.453748300 -0800
  1034. @@ -52,9 +52,9 @@
  1035. //#define coco_swprintf _snwprintf
  1036. //#elif defined __GNUC__
  1037. //#define coco_swprintf swprintf
  1038. -//#else
  1039. +//#else
  1040. //#error unknown compiler!
  1041. -//#endif
  1042. +//#endif
  1043. #ifdef WIN32
  1044. #ifndef __MINGW32__
  1045. @@ -62,7 +62,7 @@
  1046. #define coco_swprintf swprintf_s
  1047. #elif _MSC_VER >= 1300
  1048. #define coco_swprintf _snwprintf
  1049. - #else
  1050. + #else
  1051. #error unknown compiler!
  1052. #endif
  1053. #else
  1054. @@ -106,7 +106,7 @@ void coco_string_delete(char* &data);
  1055. namespace VrmlTranslator {
  1056. -class Token
  1057. +class Token
  1058. {
  1059. public:
  1060. int kind; // token kind
  1061. @@ -135,10 +135,10 @@ private:
  1062. int bufPos; // current position in buffer
  1063. FILE* stream; // input stream (seekable)
  1064. bool isUserStream; // was the stream opened by the user?
  1065. -
  1066. +
  1067. int ReadNextStreamChunk();
  1068. bool CanSeek(); // true if stream can seek otherwise false
  1069. -
  1070. +
  1071. public:
  1072. static const int EoF = COCO_WCHAR_MAX + 1;
  1073. @@ -146,7 +146,7 @@ public:
  1074. Buffer(const unsigned char* buf, int len);
  1075. Buffer(Buffer *b);
  1076. virtual ~Buffer();
  1077. -
  1078. +
  1079. virtual void Close();
  1080. virtual int Read();
  1081. virtual int Peek();
  1082. @@ -256,7 +256,7 @@ private:
  1083. int eofSym;
  1084. int noSym;
  1085. int maxT;
  1086. - int charSetSize;
  1087. +// int charSetSize; // unused
  1088. StartStates start;
  1089. KeywordMap keywords;
  1090. @@ -277,7 +277,7 @@ private:
  1091. void CreateHeapBlock();
  1092. Token* CreateToken();
  1093. - void AppendVal(Token *t);
  1094. + void AppendVal(Token *tkn);
  1095. void Init();
  1096. void NextCh();
  1097. @@ -288,7 +288,7 @@ private:
  1098. public:
  1099. Buffer *buffer; // scanner buffer
  1100. -
  1101. +
  1102. Scanner(const unsigned char* buf, int len);
  1103. Scanner(const wchar_t* fileName);
  1104. Scanner(FILE* s);