base-files: move xor() from caldata extraction to functions.sh
The xor() function is defined in each of the caldata extraction scripts for several targets. Move it to functions.sh to reduce duplicate code. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
		 Adrian Schmutzler
					Adrian Schmutzler
				
			
				
					committed by
					
						 David Bauer
						David Bauer
					
				
			
			
				
	
			
			
			 David Bauer
						David Bauer
					
				
			
						parent
						
							bba6646b5c
						
					
				
				
					commit
					c1388a2deb
				
			| @@ -17,6 +17,22 @@ NO_EXPORT=1 | ||||
| LOAD_STATE=1 | ||||
| LIST_SEP=" " | ||||
|  | ||||
| # xor multiple hex values of the same length | ||||
| xor() { | ||||
| 	local val | ||||
| 	local ret="0x$1" | ||||
| 	local retlen=${#1} | ||||
|  | ||||
| 	shift | ||||
| 	while [ -n "$1" ]; do | ||||
| 		val="0x$1" | ||||
| 		ret=$((ret ^ val)) | ||||
| 		shift | ||||
| 	done | ||||
|  | ||||
| 	printf "%0${retlen}x" "$ret" | ||||
| } | ||||
|  | ||||
| append() { | ||||
| 	local var="$1" | ||||
| 	local value="$2" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user