How is a Transaction Output Marked as Spent? The Bitcoin developer guide states that 


  each output of a particular transaction can only be used as an input once in the block chain. Any subsequent reference is a forbidden double spend—an attempt to spend the same satoshis twice.


So how does a Bitcoin network node actually mark a transaction's output as spent? I imagine it would need to be irreversible, so that other nodes cannot revert the "spent" marker, but I cannot think of a way that Bitcoin could ensure that.

Where in the standard Bitcoin code does this marking occur, and how does it occur?
Every full Bitcoin node maintains a database of which unspent outputs are left. 

When verifying a transaction, all its inputs are fetched from the database. If one is missing, validation fails. Among the data retrieved is the value of those unspent outputs, and their script (od address), which define the conditions under which the output can be spent. This information is necessary to validate whether the spending transaction has the correct signatures and does not create more bitcoin than it consumes.

If all validation of all transactions in a block succeed, the consumed inputs are removed from the database, and all outputs of those transactions added as fresh unspent outputs in the database, allowing them to be spent by future blocks.

As this database only contains outputs (so no signatures, for example), and even only the unspent ones, it is much smaller than the entire blockchain (some 450 MB as of juli 2014). So, no, we don't go scan through the entire blockchain to know whether outputs are not double-spent - we keep a separate database with just the data we need from it for validation.