🐛 now builtin_md5 uses unsigned char instead of char
This commit is contained in:
parent
396d55a207
commit
712a047a43
8
nasal.h
8
nasal.h
|
@ -3,10 +3,12 @@
|
|||
|
||||
#define __nasver "9.0"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
|
|
@ -1249,7 +1249,7 @@ std::string md5(std::string& source)
|
|||
uint32_t buffsize=num<<4;
|
||||
buff.resize(buffsize,0);
|
||||
for(uint32_t i=0;i<source.length();i++)
|
||||
buff[i>>2]|=(source[i])<<((i&0x3)<<3);
|
||||
buff[i>>2]|=((unsigned char)source[i])<<((i&0x3)<<3);
|
||||
buff[source.length()>>2]|=0x80<<(((source.length()%4))<<3);
|
||||
buff[buffsize-2]=(source.length()<<3)&0xffffffff;
|
||||
buff[buffsize-1]=((source.length()<<3)>>32)&0xffffffff;
|
||||
|
|
|
@ -257,10 +257,10 @@ void nasal_vm::stackinfo(const uint32_t limit=10)
|
|||
printf("0)\n");
|
||||
return;
|
||||
}
|
||||
printf("" PRTINT64 "):\n",top-bottom+1);
|
||||
printf("" PRTINT64 "):\n",(int64_t)(top-bottom+1));
|
||||
for(uint32_t i=0;i<limit && top>=bottom;++i,--top)
|
||||
{
|
||||
printf(" 0x" PRTHEX64_8 "",top-gc.stack);
|
||||
printf(" 0x" PRTHEX64_8 "",(uint64_t)(top-gc.stack));
|
||||
valinfo(top[0]);
|
||||
}
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ void nasal_vm::local_state()
|
|||
if(!localr || !gc.funcr.func().lsize)
|
||||
return;
|
||||
uint32_t lsize=gc.funcr.func().lsize;
|
||||
printf("local(0x" PRTHEX64 "<sp+" PRTINT64 ">):\n",(uint64_t)localr,localr-gc.stack);
|
||||
printf("local(0x" PRTHEX64 "<sp+" PRTINT64 ">):\n",(uint64_t)localr,(int64_t)(localr-gc.stack));
|
||||
for(uint32_t i=0;i<lsize;++i)
|
||||
{
|
||||
printf(" 0x%.8x",i);
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
import("test/md5.nas");
|
||||
|
||||
rand(time(0));
|
||||
srand();
|
||||
|
||||
var progress_bar=func(){
|
||||
var res=[];
|
||||
setsize(res,51);
|
||||
var (tmp,sp)=(" |"," | ");
|
||||
res[0]=tmp~sp;
|
||||
for(var i=1;i<=50;i+=1){
|
||||
tmp~="#";
|
||||
res[i]=tmp~substr(sp,i,52-i);
|
||||
}
|
||||
return res;
|
||||
}();
|
||||
|
||||
var compare=func(){
|
||||
var ch=[
|
||||
|
@ -9,7 +21,7 @@ var compare=func(){
|
|||
"^","&","*","(",")","-","=","\\","|","[","]","{","}","`"," ","\t","?"
|
||||
];
|
||||
return func(begin,end){
|
||||
var (total,prt,lastpercent,percent)=(end-begin,"",0,0);
|
||||
var (total,prt_cnt,lastpercent,percent)=(end-begin,0,0,0);
|
||||
for(var i=begin;i<end;i+=1){
|
||||
var s="";
|
||||
for(var j=0;j<i;j+=1){
|
||||
|
@ -21,13 +33,10 @@ var compare=func(){
|
|||
}
|
||||
percent=int((i-begin+1)/total*100);
|
||||
if(percent-lastpercent>=2){
|
||||
prt~="#";
|
||||
prt_cnt+=1;
|
||||
lastpercent=percent;
|
||||
}
|
||||
var tmp=prt;
|
||||
for(var spc=size(prt);spc<50;spc+=1)
|
||||
tmp~=" ";
|
||||
print(" |",tmp,"| ",percent,"% (",i-begin+1,"/",total,")\t",res," max byte: ",end-1," \r");
|
||||
print(progress_bar[prt_cnt],percent,"% (",i-begin+1,"/",total,")\t",res," max byte: ",end-1," \r");
|
||||
}
|
||||
print('\n');
|
||||
};
|
||||
|
@ -39,7 +48,7 @@ var filechecksum=func(){
|
|||
for(var i=0;i<len and s[i]!=ch;i+=1);
|
||||
return substr(s,0,i);
|
||||
}
|
||||
var filewithoututf8=[
|
||||
var files=[
|
||||
"./stl/file.nas ",
|
||||
"./stl/lib.nas ",
|
||||
"./stl/list.nas ",
|
||||
|
@ -48,6 +57,7 @@ var filechecksum=func(){
|
|||
"./stl/result.nas ",
|
||||
"./stl/sort.nas ",
|
||||
"./stl/stack.nas ",
|
||||
"./test/ascii-art.nas ",
|
||||
"./test/auto_crash.nas ",
|
||||
"./test/bf.nas ",
|
||||
"./test/bfcolored.nas ",
|
||||
|
@ -78,16 +88,21 @@ var filechecksum=func(){
|
|||
"./test/prime.nas ",
|
||||
"./test/props_sim.nas ",
|
||||
"./test/props.nas ",
|
||||
"./test/qrcode.nas ",
|
||||
"./test/quick_sort.nas ",
|
||||
"./test/scalar.nas ",
|
||||
"./test/snake.nas ",
|
||||
"./test/tetris.nas ",
|
||||
"./test/trait.nas ",
|
||||
"./test/turingmachine.nas",
|
||||
"./test/utf8chk.nas ",
|
||||
"./test/wavecollapse.nas ",
|
||||
"./test/ycombinator.nas ",
|
||||
"LICENSE ",
|
||||
"main.cpp ",
|
||||
"makefile ",
|
||||
#"nasal_ast.h ",
|
||||
#"nasal_builtin.h ",
|
||||
"nasal_ast.h ",
|
||||
"nasal_builtin.h ",
|
||||
"nasal_codegen.h ",
|
||||
"nasal_dbg.h ",
|
||||
"nasal_err.h ",
|
||||
|
@ -101,7 +116,7 @@ var filechecksum=func(){
|
|||
"nasal.h ",
|
||||
"README.md "
|
||||
];
|
||||
foreach(var i;filewithoututf8){
|
||||
foreach(var i;files){
|
||||
var f=io.fin(getname(i));
|
||||
var (res0,res1)=(md5(f),_md5(f));
|
||||
println(i,' ',res0,' ',!cmp(res0,res1),' ',size(f),' byte');
|
||||
|
|
Loading…
Reference in New Issue