comparison mxtool/mx.py @ 19863:bd953f563517

mx: followup fix for SC_ARG_MAX, add more assetions
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Mon, 16 Mar 2015 12:23:11 +0100
parents e87d55dfbbbb
children ea280aa54d58
comparison
equal deleted inserted replaced
19862:e808c8324035 19863:bd953f563517
2821 # 32,768 characters (http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx) 2821 # 32,768 characters (http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx)
2822 limit = 32768 - commandLinePrefixAllowance 2822 limit = 32768 - commandLinePrefixAllowance
2823 else: 2823 else:
2824 # Using just SC_ARG_MAX without extra downwards adjustment 2824 # Using just SC_ARG_MAX without extra downwards adjustment
2825 # results in "[Errno 7] Argument list too long" on MacOS. 2825 # results in "[Errno 7] Argument list too long" on MacOS.
2826 syslimit = os.sysconf('SC_ARG_MAX') - 20000 2826 commandLinePrefixAllowance -= 20000
2827 syslimit = os.sysconf('SC_ARG_MAX')
2827 if syslimit == -1: 2828 if syslimit == -1:
2828 syslimit = 262144 # we could use sys.maxint but we prefer a more robust smaller value 2829 syslimit = 262144 # we could use sys.maxint but we prefer a more robust smaller value
2829 limit = syslimit - commandLinePrefixAllowance 2830 limit = syslimit - commandLinePrefixAllowance
2831 assert limit > 0
2830 for i in range(len(files)): 2832 for i in range(len(files)):
2831 path = pathFunction(files[i]) 2833 path = pathFunction(files[i])
2832 size = len(path) + 1 2834 size = len(path) + 1
2835 assert size < limit
2833 if chunkSize + size < limit: 2836 if chunkSize + size < limit:
2834 chunkSize += size 2837 chunkSize += size
2835 else: 2838 else:
2836 assert i > chunkStart 2839 assert i > chunkStart
2837 yield files[chunkStart:i] 2840 yield files[chunkStart:i]